Make Mouse Screen Position Affect Object Rotation

I’ve done this so far >


but the problem is that it only works on the half of the left side of the screen and doesn’t even rotate to the full parameter that I’ve set (-90min 90max) >

It’s a bit unclear what are you trying to achieve.
Do you want the cannon to always point towards the mouse ?
Or do you want mouse movements to rotate the cannon, regardless of where the mouse is ?

Agreed, it’s unclear how you want it to rotate. The above does not work because the mouse position outputs values in the range 0-1920 if that’s the resolution / viewport size you’re using. This is around 90px only:

image


This is closer but not enough, most likely:

You’d still need to deal with relative rotation if the whole tank can rotate, too. But to advise, we’d need to know more about how it all works.

Do tell.

Thanks for replying! I hope this clears up what I’m trying to achieve a bit more


I want the canon to rotate 180 0r 90 degrees only in that range

And yes the vehicle does rotate as well

This worked beautifully >


but now the only issue is the relative rotation >

THANKS A TON @Everynone !! Your code was all the code I needed actually, all I added was relative rotation of the arrow >