private bool hitted = false;
private Vector3 hitPosition;
private void Test()
{
RaycastHit hit;
if (Physics.Raycast(start.position, Vector3.left, out hit, 1.5f)
|| Physics.Raycast(start.position, Vector3.right, out hit, 1.5f)
|| Physics.Raycast(start.position, Vector3.forward, out hit, 1.5f))
{
if (hit.transform.tag == "Test")
{
hitted = true;
hitPosition = hit.transform.localPosition;
}
}
}
private void Update()
{
if (hitted == true)
{
player.localRotation = Quaternion.Lerp(player.localRotation, Quaternion.LookRotation(hitPosition), 1 * Time.deltaTime);
}
}
What i want to detect is when the player finished rotating and then set back hitted to false.