Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Napstaguy04 |
I’m fairly new to game programming. I tried replicating this effect from Polymar’s video (https://www.youtube.com/watch?v=iEn0ozP-jxc&t=136s, around 4:31) where he makes his arrow sprite turn away from the mouse by using a trigonometric function.
However, when I tried replicating the code in godot, the sprite just ends up rotating in a different way than intended, sometimes sporadically turning and slowing down in random angles. Here’s the code that I’ve written:
extends Sprite
func _process(delta):
rotation = atan2(position.y, get_global_mouse_position().x)
pass
Are there extra parameters that I need to insert? Or have I made the code wrong? Help is appreciated, thanks!