0 votes

I am currently following this tutorial video
https://www.youtube.com/watch?v=iOYv4HLWDh0

it is a really simple scene, all I have is a node 2D root and a sprite. and this is my code

extends Sprite
var mousepositoion

func _process(delta):
    mousepositoion = get_local_mouse_position()
    rotation+= mousepositoion.angle() * 0.1

which is the same as the video. But result from mine is different. Lets say if I move my cursor directly above the sprite, it would rotate to the left and if I move my cursor to the right, the it would face up. I am not sure what I did wrong here .

Note: I also tried look at which also have the same result. I am quite confused what I did wrong
Edit : I tried $Sprite.rotation= rad2deg(90.0) and result is strange, it didn't rotate 90 degress rather it seems to rotate something like 92 degrees. I am scratching my head here

in Engine by (170 points)
edited by

1 Answer

0 votes
Best answer

A rotation of 0 degrees represents pointing to the right (along the x-axis). Since the image you're using is drawn pointing upwards, it's going to be 90 degrees off from what look_at() is doing. Set the Sprite's rotation in the Inspector to 90, and you'll be fine.

BTW, rad2deg(90) converts 90 radians to degrees, which is 5156 degrees. What you want there is deg2rad().

by (20,679 points)
selected by

Thank you so much for helping. I actually end up drawing a arrow point to right and it worked. It is nice to know the the origin is right facing. As for rad2deg...that was me just being stupid. Thanks again

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.