Hi. Iv’e been trying to make this work all day, and would greatly appreciate some help!
Im making a 2D birds eye view game. There is a sprite with a script attached, and I want him to rotate on the Z axis to point at my mouse cursor. Right now with my code though, he becomes invisible to the camera because t=he starts rotating on the Y and X axis! Please help much confused, thanks. CODE:
//vector for current mouse position(works)
var mouse = Vector2(Input.mousePosition.x,Input.mousePosition.y);
Debug.Log(mouse);
//does something..
var relativePos = mouse - transform.position;
//sets sprite rotation to relativePos
transform.rotation = Quaternion.LookRotation(relativePos);