0 votes

I'm trying to do a rudimentary spin attack with a sword by having the sword spin around my player. The problem is that when the sword moves past a certain point in the animation, it will rotate excessively in the wrong direction in order to match up with its rotation key.

I've narrowed this down to notice that it only happens when simultaneously rotating an object past a certain threshold (from negative to positive degrees or vice versa) and translating that object over an axis. It looks like the animation player is struggling to find the actual shortest path for the animation.

Here is a video recording of the behavior I am describing:
https://www.youtube.com/watch?v=me15zlZESUE

Godot version 3.2.3
in Engine by (52 points)

I found this question here, is the newest answer helpful? Looks like there was an issue once about it but it was closed and never re-opened or referenced again because it wasn't categorized correctly... I didn't see if anyone proposed it as a feature since this was closed.

It's very similar to what I'm asking, but I would like to be able to use the editor to solve this rather than code.

1 Answer

0 votes

you can set a fixed distance between your sword center and the player center so the sword can spin its center around the player center

func _set_sword_distance(): 
    var player_position: Vector2 = (player.global_position - global_position).normalized()
    var player_to_sword: Vector2 = sword.position - player_position
    var sword_direction: Vector2 = player_to_sword.normalized()
    var sword_vector: Vector2 = sword_direction * sword_distance
    var final_position: Vector2 = player_position + sword_vector
    sword.position = final_position

than you can rotate your sword freely and it will keep that same sword_distance and axis with the player no matter what he does

by (360 points)
edited by

you will probably need to place the center of the sword node on its bottom so when it spins it looks right.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.