Question by
nikee9716 · Mar 27, 2020 at 10:26 PM ·
raycastraycasthitdrawing
Drawing Raycast Problem,Drawing Multiple RaycasT Problem
Hi. Sorry for using Google translate. My problem is ;
I use 2 raycast. The first one is for the aiming, 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 Rotasyon()
{
RotationFareKontrol();
if (Horizontal != 0 || Vertical != 0)
{
Physics.Raycast(Vector3.zero, kafakamerasi.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);
Debug.DrawLine(Vector3.forward, hit.point);
}
}
void Rotasyon2()
{
RotationFareKontrol();
Physics.Raycast(Vector3.zero, kafakamerasi.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);
Debug.DrawLine(Vector3.zero, hit.point);
Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f));
Physics.Raycast(ray,out hitates);
Debug.DrawLine(ray.origin, hitates.point);
}
void RotationFareKontrol()
{
kafakamerasi.transform.position = transform.position + kameraArasimesafe;
KafarotUstAlt += Input.GetAxis("Mouse Y") * Time.fixedDeltaTime * -150;
KafarotSagSol += Input.GetAxis("Mouse X") * Time.fixedDeltaTime * 150;
KafarotUstAlt = Mathf.Clamp(KafarotUstAlt, -19, +19);
kafakamerasi.transform.rotation = Quaternion.Euler(KafarotUstAlt, KafarotSagSol, transform.localEulerAngles.z);
}
,
Comment
Your answer