Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Vector3 cursorPosition = camera.ScreenToWorldPoint(Input.mousePosition);


Vector2 direction = (cursorPosition - transform.position).normalized;

transform.right = direction;


This would rotate the player to face in the direction of the mouse.

No need for anything else.

This is how I rotate the gun in our game. 

(+1)

Thank You! Aargh!!! I spent so much time coming up with some horrendous equation to calculate the z rotation from the lookat output!!! Why didn't I think of that??? That is so much simpler! Thank you!

(1 edit) (+1)

Felt the same when I first found out... xd

Glad to help. :)