Discord
Login
Community
DARK THEME

my code is not working

rotation=atan((mouse.y-y)/(mouse.x-x))

its supposed to make them rotate

rotation = atan2d((mouse.y-y), (mouse.x-x))

Note that screen.setRotation(angle) takes degrees, but atan and atan2 return radians, so use the "d" variants (unless you're doing something else that requires radians). You should prefer atan2 and atan2d, because it helps you avoid the situation where mouse.x is equal to x and you end up dividing by zero.

i don't fully understand how or why but it works.

thanks

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community