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.

AppGameKit Classic Chat / controlling 3D character animations with movement

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 13th May 2018 21:10
having problems thinking of the logic to have animations playing, say w to walk, becauswe of course if you keep w pressed in it will restart at frame 0:

the thing is I have seperate fbx files,one for walk,the other jump,and so on,as I was unable to join fbx files, this works fine, here is the code


as you see I have to delete myplayer before I clobe it with the correct object+ animations, but how do /I say to just play the animation all the way through! as everytime w is pressed it start at frame 0
Hail to the king, baby!
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 13th May 2018 21:26 Edited at: 13th May 2018 21:27
I'd recommend implementing a concept of character states. The control input then doesn't affect the character directly, it sets a state. A separate character update then looks at the states and determines how to update the character object.

say you have the character's 'action state' set to 'idle'
You press/hold W which sets the action state to 'moving'
when you detect that the state has changed from idle to moving, you can trigger a loop walk animation
while the state remains moving, you can move the objects position
You release W which sets the state back to idle
when you detect that the state has changed from moving to idle, you can trigger a stop animation and/or loop an idle animation

by abstracting away the resulting update actions from the input controls, you can then also use the same character update process to handle AI NPCs, you can set thier states by an AI update instead of the player's direct inputs, but the character update process doesn't need to know how the states were set.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 13th May 2018 21:31 Edited at: 13th May 2018 21:46
it seems to get messy though as i need a few animations!, walk,run,jump and idle
I basically need to be shown with some rough code!
Hail to the king, baby!
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 14th May 2018 02:08 Edited at: 14th May 2018 02:16
Quote: "I basically need to be shown with some rough code!"




The above should work well if you set the animations to loop
fubar

Login to post a reply

Server time is: 2024-03-28 10:02:43
Your offset time is: 2024-03-28 10:02:43