Best way to trigger a method at the end of an animation (callback or wait for end of animation)

Options
Hello,

I'd like to know what is the best way to handle a callback at the end of an animation with Bolt.
For example, a player casting a fireball.
Should I wait for the end of the animation in a co-routine (that is executed on the server), or add a callback to a method in the animation (and send an event to trigger the gameplay)?

Thanks.

Comments

  • Majicpanda
    Options
    If you're making it authoritative I could see events baked into animations causing some major issues since you technically need to release the fireball earlier on the server to accommodate the caster's latency. In general, animation events I think are deemed bad practice for actual important game logic.

    I would go with defining casting time to match your animations and coroutine to simply wait cast time. I do this for grenades currently. The controller sends his grenade toss input and simulates the animation immediately locally, if he has a 100ms ping and the animation is 1000ms then you're already behind by 100ms and need to play with offsetting the servers coroutine wait time that dispatches a Bolt Event to all clients so they see the projectile (projectile id, pos, rot event etc).
  • laurel
    Options
    Hi Majic,

    Thanks for the clarification.
    I have another question then. How do you catch up with the server? Do you compare the time the server receives the input and the time the controller sends it by adding it to the input? Do you then substract the difference between the two?

    Would you mind sharing a snippet of your code for this part?

    I would guess you do the same with the missile part? Right now my missiles are triggered by the server, but I do not update the position as the missile flies in the env.