- Home /
This question was
closed Apr 12, 2013 at 08:07 PM by
fafase for the following reason:
The question is answered, right answer was accepted
Question by
azmundai · Apr 12, 2013 at 07:43 PM ·
coroutinewaitforsecondsnullienumeratorontriggerstay
Need Help with a Null Reference
Error : NullReferenceException: Object reference not set to an instance of an object PoisonCloudHealthAdjustment.OnTriggerStay (UnityEngine.Collider other) (at Assets/Scripts/PoisonCloudHealthAdjustment.cs:16)
using UnityEngine;
using System.Collections;
public class PoisonCloudHealthAdjustment : MonoBehaviour {
IEnumerator TriggerPause(int wait, GameObject pauseObject)
{
pauseObject.collider.enabled = false;
yield return new WaitForSeconds(wait);
pauseObject.collider.enabled = true;
}
void OnTriggerStay(Collider other){
if(other.tag == "Player" )
{
if(gameObject.GetComponent<CreatePlatforms>().gameMode == 2) gameObject.GetComponent<PlayerHealth>().curHealth -= 1;
StartCoroutine( TriggerPause(2, gameObject) );
}
}
void Start()
{
StartCoroutine( TriggerPause(1, gameObject) );
}
}
Is the Coroutine messing up the collider or something?
Thanks :)
Comment
Best Answer
Answer by azmundai · Apr 12, 2013 at 08:06 PM
I fixed it .. CreatePlatforms is on a different gameObject. /facepalm
Follow this Question
Related Questions
Can't get past WaitForSeconds in my coroutine 1 Answer
Coroutine doesn't work when called from another method. 3 Answers
OnCollisionEnter as IEnumerator problem (WaitForSecond) 2 Answers
Delay after input? 1 Answer
How to stop coroutines, when paused 2 Answers