- Home /
Question by
Chocolade · Oct 25, 2016 at 05:04 PM ·
c#scripting problemscript.
How can i prevent from mouse to collide with thirdpersoncontroller ?
The condition: hit.collider.name != "ThirdPersonController" is working for the first part but not for the second part. And if i add inside the else part also this if: hit.collider.name != "ThirdPersonController" condition it will not work right. I want when i move the mouse and the player rotate that if the mouse is on the player don't rotate it. But the condition is working fine only for the first part not for the else.
RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit) && hit.collider.name != "ThirdPersonController")
{
transform.LookAt(hit.point);
}
else
{
transform.LookAt(ray.GetPoint(100));
}
Comment