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 / Toggle from walking to running

Author
Message
Fantazar
21
Years of Service
User Offline
Joined: 14th Jul 2003
Location:
Posted: 29th Sep 2003 14:19 Edited at: 29th Sep 2003 14:21
Being fairly new to Dark Basic I’d like to ask how I can use a toggle key which when pressed once I’m then able to run instead of walking and viceverser?
This is what I use so far to walk around see source below
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 29th Sep 2003 17:01
Well, the simple method would be to have a speed variable to control the player speed, this would do it pretty smoothly, but you'll have to mess with it to get it nice for your particular game.



The toughest thing to get smooth is the player animation, here's a good method for smooth integration.

* Split the animation into sets, sets 1 to 3 are for walking, sets 4 to 6 are running, like:

Set 1 - Standing still to walking.
Set 2 - Walking loop.
Set 3 - Walking to standing still.
Set 4 - Standing still to Running.
Set 5 - Running loop.
Set 6 - Running to standing still.

Now, the idea is you start at set 1, and if at the end of set 2 the player is still walking, you reset the frame to the start of set 2 again, if you stopped walking then the player slows down to a halt. This would give nice professional movement. You can simply replace the sets for when the run key is pressed, but only change to the running set when looping the animation - it'll look smooth as silk if your careful with the running to walking transitions. To use this method, it's best to apply the speed to the positions outside of the control conditions, so the keys adjust variables like angle and speed, and all the movement is independent, this will allow gradual stops using the animations properly too - because the speed can slow down to a crawl, or you can just set the speed to 0 when the frame gets passed the last set and it's left in the standing pose.


Van-B

My cats breath smells of cat food.

Login to post a reply

Server time is: 2024-09-21 01:13:42
Your offset time is: 2024-09-21 01:13:42