Im trying to use the coroutine to delay an action below and then carry out the functions i have , but is does not seem to be working , im lost with this one
using UnityEngine;
using System.Collections;
public class RingScript : MonoBehaviour {
public bool inForceTrigger;
public bool inSecondForceTrigger;
public bool inRoofTrigger;
public bool inHookTrigger;
IEnumerator GetOutOfCollider (float delay)
{
yield return new WaitForSeconds(delay);
transform.FindChild ("Sphere").gameObject.SetActive (true);
transform.FindChild ("Box").gameObject.SetActive (false);
}
void OnTriggerEnter (Collider other)
{
if (other.tag == "RoofCollider")
{
inRoofTrigger = true;
}
if (other.tag == "LowHookTrigger")
{
inHookTrigger = true;
}
if (other.tag == "SecondForceCollider")
{
inSecondForceTrigger = true;
}
if (other.tag == "ForceCollider")
{
inForceTrigger = true;
}
}
void OnTriggerExit (Collider other)
{
if (other.tag == "RoofCollider")
{
inRoofTrigger = false;
}
if (other.tag == "LowHookTrigger")
{
inHookTrigger = false;
}
if (other.tag == "SecondForceCollider")
{
inSecondForceTrigger = false;
}
if (other.tag == "ForceCollider")
{
inForceTrigger = false;
}
}
void FixedUpdate ()
{
if (inRoofTrigger == false inHookTrigger == false inSecondForceTrigger == false inForceTrigger == false )
{
transform.FindChild ("Box").gameObject.SetActive (false);
transform.FindChild ("Sphere").gameObject.SetActive (true);
rigidbody.constraints = RigidbodyConstraints.None;
rigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete;
}
if (inRoofTrigger == true)
{
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
}
if (inRoofTrigger == true transform.FindChild("Box").GetComponent<BoxScript>().boxInHookTrigger == false )
{
StartCoroutine(GetOutOfCollider(10.0f));
}
if (inHookTrigger == true )
{
transform.FindChild ("Box").gameObject.SetActive (true);
transform.FindChild ("Sphere").gameObject.SetActive (false);
rigidbody.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
rigidbody.AddForce (1, -2,0);
}
if (inSecondForceTrigger == true)
{
rigidbody.AddForce (6, 0,0);
}
if ( GameObject.FindWithTag("Level01GUI").GetComponent<GUIScript>().buttonPress inForceTrigger == true )
{
rigidbody.AddForce (200, 900,0);
}
}
}