0 votes

I know how to get the length of a vector 2 but there is something similar for rotation.

velocity =  Vector2()
in Engine by (181 points)

Not sure I follow. What do you consider the length of a rotation? Maybe the length of the arc segment between rotationA and rotationB at some (yet-to-be-specified) distance?

If you mean how to get the rotation from a Node2D, just use its rotation property as follows:


1 Answer

0 votes

Both jgodfrey and _magicalogic_ are right: You can't get a "length of rotation" without specifying a radius. You can either get the angle with $My_Node.rotation (like _magicalogic_ said), or get the length of the arc segment at a specific radius, like jgodfrey said. For the latter, there's no inbuilt function (as far as I'm aware), but you can easily create one yourself:

func get_length_of_rotation (angle: float, radius: float) -> float:
    var circumference : float = 2.0 * PI * radius
    var fraction : float = angle / (2.0 * PI)
    return circumference / fraction
by (1,648 points)
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.