Hi. Sorry for using Google translate. My problem is ;
I use 2 raycast. The first one is for the camera, that is, for the character to rotate(horizontal-vertical). 2. raycast to control the body. But the 1st ray sometimes coincides with the 2nd ray. And my character perceives the 1st track. He’s doing strange moves. How do I prevent this?
void Rotasyon2()
{
RotationMouseControl();
Physics.Raycast(Vector3.zero, headcam.transform.GetChild(0).forward, out hit);
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(new Vector3(hit.point.x, 0, hit.point.z)), 0.3f);
Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f));
Physics.Raycast(ray,out hitfire);
}
void Rotasyon()
{
RotationMouseControl();
if (Horizontal !=0 || Vertical !=0)
{
Physics.Raycast(Vector3.zero, headcam.transform.GetChild(0).forward, out hit);
transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(new Vector3(hit.point.x,-0, hit.point.z)), 0.3f);
}
}