Unity lookat at finger position 3D C#
Hello, I am developing a 3D game and I want the character object to follow my finger, but I want it to only spin on the z axis I tried to use this - but it definitely didn't rotate on the z axis:
if (Input.GetMouseButton(0))
{
transform.LookAt(Input.mousePosition);
}
I used to have it as when you click on the side of the screen it rotates the char for testing purposes, but I can't figure out or find how I could make it follow my finger while only rotating on the z axis.
if (Input.GetMouseButton(0))
{
if (Input.mousePosition.x > Screen.width / 2)
transform.Rotate(0, 0, -rotateSpeed);
else
transform.Rotate(0, 0, rotateSpeed);
}
Comment