Hi guys i need help making a collider disabled for two seconds when collided with the player and reenable it after 2 second.Everytime my Player collides with the collider it adds 1 score so i need a script to disable it for 2 seconds when collided with the player so that the player cant collide 2 times and get double score and then reenable again.Here’s my current script but i keep getting an error.Thanks
using UnityEngine;
using System.Collections;
public class ScorePoint : MonoBehaviour {
void OnTriggerEnter(Collider collider) {
if(collider.tag == "Player")
Score.AddPoint(
(Collider = false)
(WaitForSeconds (2)
(Collider = true)
}
}
Thanks guys i finally have a working script awesome!
Heres the final code and i think figured out where to put ; and ) stuff
using UnityEngine;
using System.Collections;
public class Score2 : MonoBehaviour {
IEnumerator OnTriggerEnter(Collider collider) {
if(collider.tag == "Player") {
Score.AddPoint();
gameObject.collider.enabled = false;
yield return new WaitForSeconds (2);
gameObject.collider.enabled = true;
}
}
}