- Home /
Question by
DennyFarts · Mar 22, 2017 at 03:28 AM ·
rotationlookatrotation axisrotatinglookrotation
LookRotation is Returning Weird Values
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.
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.
help14-14.jpg
(286.4 kB)
Comment