Make animation rotate towards global_mouse_position

Godot Version



Hi! I’m trying to make the swing attack animation for my character look_at() the position of my current mouse position, but I’m having some difficulties playing the entire animation towards that direction.
The animation consists of 6 property tracks, position + rotation for the “attack texture” (the white swing effect going away from the player), position + rotation for the actual weapon swinging (in this case, a stick swinging upwards) and position + rotation for the player HurtBox, which is the yellow square.


I’ve already tried using look_at(get_global_mouse_poisition()), but I can’t assign it directly to the AnimationPlayer node, and assigning it just to the sprite nodes for the weapon and the attack texture would just rotate them on themselves, not change the direction at which the texture is going (for example, if I would click above the player, it would still just move right because of how AnimationPlayer set it up to move towards position.x)

How would I go about rotating this entire animation towards the global_mouse_position? Is there an easier way to do this? Thank you in advance.

Use a parent Node2D as a pivot of the animation/attack and rotate that node with look_at()

Sorry for the late reply, but I’ve made a few attempts at trying this and not much seems to work. I’ve called the pivot “AnimRotator”, and the hierarchy of nodes is as follows: AnimRotator > AnimationTree > AnimationPlayer (which contains the swing animation).
AnimRotator seems to rotate fine, but the AnimationPlayer seems to not follow the parent’s rotation, they don’t interact.
Is this because AnimRotator is not a direct parent? If so, how could I fix this? Because I don’t think I can just remove the AnimationTree node from the equation

Neither AnimationTree nor AnimationPlayer are the nodes that contain the textures.
AnimRotator should be the direct parent of the attack swing texture node.

But if I want to rotate the whole animation, rotating just the texture wouldn’t make it play towards the position I’m looking for, but just rotate the weapon/swing texture to face that certain point, while the animation would still just play towards the left, or am I completely wrong?