0
votes

I'm doing a game in Godot, and I created a simple move animation with AnimationPlayer that moves the node from position A to position B. The animation is two keyframes.

Now I want to change position B with code, how can I do it?

I was thinking something like this:

func moveTo(pos):
    get_node("animation").get_animation("move").get_keyframe(1).set_pos(pos)
    get_node("animation").play("move")
1

1 Answers

1
votes

You need use the _process(delta) to do this. Animations are constant and can not be changed during execution.

You can use the look_to(position) and translate(0,0, delta) functions while you are away from position.

If it is a location with obstacles, you can use a navmesh to move the node.