Hello! Sooo, I’m making a top-down shooter, with a control scheme similar to the game Hotline Miami, and I’m having trouble getting the character to face towards the mouse pointer. I tried using Ray Casting, but when I do that, the character spazzes out if I move the mouse underneath him, or on top of a wall. Here’s the script:
var lookTarget : Vector3;
function Update()
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
{
lookTarget = hit.point;
}
transform.LookAt(lookTarget);
}
How can I make it so the character ONLY rotates along the Y axis? Thanks for the help.