0
\$\begingroup\$

Here is my jumping code:

if is_on_floor():
    if Input.is_action_just_pressed("ui_up"):
        motion.y = JUMP_HEIGHT
    if friction == true:
        motion.x = lerp(motion.x, 0, 0.2)
else:
    if motion.y < 0:
        $Sprite.play("Jump")
    else:
        $Sprite.play("Fall")
    if friction == true:
        motion.x = lerp(motion.x, 0, 0.05)

But I want also add the somersault animation at top point like in Contra games from NES. How can I detect moment where I should play and stop this animation. Should it be related to animation frames count and play speed?

\$\endgroup\$
2
  • \$\begingroup\$ Just playing animation once at appropriate velocity doesn't do the trick? \$\endgroup\$
    – Ocelot
    Jun 18, 2020 at 22:12
  • \$\begingroup\$ @Ocelot in that case that speed will depends on animation speed \$\endgroup\$
    – Robotex
    Jun 23, 2020 at 12:24

0

You must log in to answer this question.

Browse other questions tagged .