system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
James122333 |
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
system
2
|
|
|
|
Reply From: |
Coxcopi |
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()
)
The rotate()
method takes radians as input, not degrees. So, to use it with degrees, first, convert them to radians like:
rotate(deg2rad(45))
jgodfrey | 2020-12-25 15:07
You’re right, I completely forgot to add that, edited the answer. Thanks for the reminder!
Coxcopi | 2020-12-25 15:21