#Design question: Player Input and Animations

11 messages · Page 1 of 1 (latest)

dense axle
#

Hey all, I have a problem I've been working on for some time now regarding player input and animations based on player input.

Currently I have most of my current animations working as intended, except for a few combat animations. Before I end up getting too deep into my program, I'd like to just ask -- for a multiplayer RPG game, how closely tied should player input and animations be together? Right now I have three separate systems: one for handling input, one for handling animations, and one for sending/receiving updates from the server for player position/actions/etc.

Right now I'm struggling with trying to get my combat animations to work exactly how I want. Essentially, when the player hits the 1 button, i just want the animation to play once, but it plays repeatedly. This is due to utilizing a boolean for whether or not my event reader see's that the player pressed the 1 button. But I want the animations to play all the way through, without interruption should the player repeatedly spam the 1 button. In addition, I'm wanting the damage values to be calculated only once per play through, not per update tick which is how it's currently doing so. I realize the way I'm doing things are not exactly the most optimal, but at the moment, especially since I'm deep into the learning process, I'm not terribly concerned with optimal compared to wanting to get things in a working-as-intended state.

#

I have a lot of commented out portions from trial and error. Please ignore them for the moment. Any suggestions for moving in the right direction would be greatly appreciated 🙂

marble wharf
#

I don't know much about animation, here are some ideas (I have to say I didn't read your code completely, it was just too long):

  1. when the player presses a key, add a component for the player that has a timer, write another system to handle this timer (which is the part of your animation that plays), and delete the component when the timer expires.When the player presses repeatedly, just determine if this component exists, and if it does, do nothing.
  2. Calculating damage is a different system, querying Added<T>
fading spade
#

You can also make state component to avoid adding and removing it. The state component would be in charge of determining which animation transtions are allowed as well as making sure you can restart/queue animation by pressing buttons repeatedly.

dense axle
#

Hey yall, I really like both ideas! I'll play around with both suggestions and see where we get.

dense axle
fading spade
#

Thay may sounded like some nice feature but I just meant an enum component that would have a state of animation like Idle, Moving etc with some metadata stored per each animation. Then depending on current state you can make decision in your system when the input comes.

#

Ie, If you are already in Moving animation state and event comes - just ignore it

dense axle
#

I was thinking of actual state changes per animation, which I guess could work but would make things way more complicated than it should be :P, but your idea makes more sense. Thank you!

fading spade
#

You can also try to explore if there are any State Machine crates for bevy that would make it easier to define your states and transitions between them