Ok so the main idea is that if object camera coliding with one of “waypoints” then it start to check camera’s Y angle. Then appear message that player need to turn himself 360’ and if he done it the message gone. Problem is that how to check that he made it +360.
Also in the moment of collide rotate also multiplied by 3 (rotCoef).
void setNewData()
{
Camera cam = GetComponent<Camera>();
cam.SetStereoViewMatrix(Camera.StereoscopicEye.Left, cam.worldToCameraMatrix);
cam.SetStereoViewMatrix(Camera.StereoscopicEye.Right, cam.worldToCameraMatrix);
Player1.transform.localPosition = getPosition();
Player1.transform.localRotation = getRotation();
angleSoFar = 0;
if (colideme == true)
{
rotCoef = 3.001f;
spinerMSG = true;
angleSoFar = cam.transform.localEulerAngles.y;
}
if (angleSoFar > collisionangle)
{
deactivator();
}
}
private void deactivator()
{
if (angleSoFar > coefka)
{
colideme = false;
spinerMSG = false;
angleSoFar = 0;
collisionangle = 0;
rotCoef = 1f;
}
}
private void OnGUI()
{
if (spinerMSG == true)
{
GUI.Label(new Rect(0, 0, 100, 50), "SPIN 360 Degrees!");
}
}
private void OnCollisionEnter(Collision col)
{
Camera cam = GetComponent<Camera>();
if (col.gameObject.tag == "waypoint")
{
collisionangle = cam.transform.localEulerAngles.y;
if (collisionangle < 3.0949f || collisionangle >= 0f)
{
coefka = collisionangle + 356.905f;
}
if (collisionangle >= 3.0949f)
{
coefka = (collisionangle + 356.905f) + 360f;
}
Debug.Log("Colided");
Debug.Log(collisionangle);
colideme = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "waypoint")
{
GameObject temp = waypoints.transform.GetChild(0).gameObject;
foreach (Transform child in waypoints.transform)
{
Destroy(temp);
}
}
}