0 votes

Help! How to code an object to rote a specific degrees
(I have no idea)

I want to create a 2d game where when pressing a button an object rotates 45 degrees

in Engine by (58 points)

1 Answer

+1 vote
Best answer

You can simply use the rotate() function for 2D nodes, so in your case:

rotate(deg2rad(45))

(As jgodfrey pointed out already, the rotate() function uses radians, so to convert your 45 degrees you need to use deg2rad())

by (312 points)
selected by

The rotate() method takes radians as input, not degrees. So, to use it with degrees, first, convert them to radians like:

rotate(deg2rad(45))

You're right, I completely forgot to add that, edited the answer. Thanks for the reminder!

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.