Topic was automatically imported from the old Question2Answer platform.
Asked By
Tentamens
Hi there!
I’m trying to add rotation to the character by 90-degree intervals in my game but whenever I try to rotate the player with rotate() or rotation = it will turn it 90 degrees in the code (like if I print it out it says 90 180 ext.) but when I look at it in the game it looks more like it rotates 60 degrees at a time, I have zero ideas why this is I’ve tried many different things but none work so if you can help big thanks!!
You don’t show any code, so only guessing, but I assume you’re supplying a value in degrees when a value in radians is expected?
If necessary, you can convert between them via the in-built deg2rad() and rad2deg() functions.
that is not the problem I am facing.
sorry forgot to add the code so here it is
if direction.x == 1:
player.rotate(90)
movement_right()
if direction.x == -1:
player.rotate(-90)
the problem I’m experiencing is visually its not rotating enough visually but if I print the rotation its correct right
this is using the code listed above rotating 90 degrees at a time. Imgur: The magic of the Internet
Big thanks for the help! been struggling with this for a while
Tentamens | 2022-07-21 19:58
I think that IS the problem you’re facing…
What happens if you change your code (in both places) to something like this?
player.rotate(deg2rad(90))
jgodfrey | 2022-07-21 20:01
Without that deg2rad() call, you’re telling the engine to rotate your player 90 radians, which is 5156.62 degrees.