How to make smooth steping animation

Godot Version

4.3

Question

Hi, I’m new to Godot and GameDev, so I’m missing a lot of knowledge, but: I’m trying a make smooth animation for aiming using blend. I have reached solution, but I really don’t like it.

Simplified example:

  • Animations are non repeating rotation of 45° “tilt to left” and “tilt to right”

  • This is my Animation tree:

  • I’m stepping 15° with attempting smooth transition between steps

  • Just setting up the blend will result in animation playing only once for each direction:
    Not Working

    • setting animation on repeat jut makes it bounce constantly.
  • I have solved this by updating the blend value continuously by code, where current_position is set as the blend value

	elapsed_delta += delta
	current_position = lerpf(
		current_position,
		destination_position,
        # min to cap if delta is to big (for example clicking out of window in middle of animation)
		min(animation_step * elapsed_delta, abs(destination_position - current_position))
	)
  • result:
    Working But with wierd script

I believe THIS is ugly solution and there has to be something that I’m missing, but I looked everywhere I could think of and found nothing.

If you just want to tilt it you could do that procedurally via code:

@export var rotation_tween : Tweens
@export var rotation_duration : float
var target_rotation : float

func _ready():
   target_rotation = rotation_degrees


func rotate(degrees : float):
   target_rotation += degrees
   rotation_tween.tween_property(self, "rotation_degrees", target_rotation, rotation_duration)
1 Like

Thank you,
It wont be simple rotation, but reading the docs for Tween and I can imagine how to solve most of my issues wit it, thanks a lot. Seems like this is the node that is here exactly for my usecase.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.