Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Moving a character and controlling its animation

Author
Message
Thraxas
Retired Moderator
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: The Avenging Axe, Turai
Posted: 24th Oct 2009 10:15 Edited at: 24th Oct 2009 11:13
I am just trying to load a character and move it around while its walking animation plays.

I am having trouble doing this seeming simply thing

I am not very good at coding so apologies if my code is very bad. I have loaded the character up and just want to use the arrow keys to move it around.

The character loads but if I press the up arrow it walks backwards. So I thought I would be clever and YRotate Object the character on load but it still goes backwards

I also can't work out how to stop the animation playing once you stop moving. I tried checking if no keys were pressed but then the animation wouldn't play when it was walking.

I'd also like to use the left/right arrow keys to rotate the character, but again I don't seem to be able to that either. I thikn I need to check what direction I'm facing and then add/subtract from it but the character just 'jumps' to the different direction, and seeing as I can't even get it to go forwards or backwards properly yet I got rid of that code. Any tips on how I would go about doing that would be appreciated.

I attached the executable that goes with the code below so you could see what it does so far.



EDIT
I figured out turning the player, and I edited the code so that the player walks forward by making the movement speed negative to go forward. This doesn't really make sense to me but it works for now. So really I just need to know how to stop the walking animation when the character is stationary. Here's the edited code:



Of course if my code is hideously wrong and I could do things in a much simpler way, I would love to know.

Attachments

Login to view attachments
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 24th Oct 2009 11:22 Edited at: 24th Oct 2009 11:23
Your model seems to be facing the opposit direction by default

Try this:



and this:



declare playerangle# as global before the do-loop
Thraxas
Retired Moderator
18
Years of Service
User Offline
Joined: 8th Feb 2006
Location: The Avenging Axe, Turai
Posted: 24th Oct 2009 12:25
Thanks very much Scorpyo, that works a treat

Login to post a reply

Server time is: 2024-09-28 12:21:21
Your offset time is: 2024-09-28 12:21:21