I have no idea why this is happening, but in the picture below, it shows my console returning values that are different from my gameObject's rotation values and the time it returned the lookRotation values was right after it rotated.
![alt text][1]
[1]: /storage/temp/90372-help14-14.jpg
Also, I have some code for you to look through to check if there are any errors:
if (dist <= shootingRad && isInIEnum == false)
{
RaycastHit hitTwo;
Ray rayTwo = new Ray(transform.position, Vector3.forward);
if (Physics.Raycast(rayTwo, out hitTwo))
{
if(hitTwo.transform.tag == "enemy" || Quaternion.LookRotation(GetClosestEnemy(bearsTransform).position) != transform.rotation)
{
Debug.Log("hit " + hitTwo.transform.name);
findNeareset = true;
}
}
}
RaycastHit hit;
Ray ray = new Ray(transform.position, Vector3.forward);
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.tag == "rocket")
{
Debug.Log("hit " + hit.collider.name);
findNeareset = false;
}
}
}
private IEnumerator findClosest()
{
isInIEnum = true;
yield return new WaitForSeconds(3);
transform.LookAt(GetClosestEnemy(bearsTransform));
Debug.Log(Quaternion.LookRotation(GetClosestEnemy(bearsTransform).position).eulerAngles);
Instantiate(rocket, spawnLoc.position, transform.rotation);
findNeareset = false;
isInIEnum = false;
}
Please get back to me soon, I've been working on this project for about two days on this specific problem. Best Regards, Dennis.
↧