- Home /
Collision With Trigger, Then Add Points To Counter, Then Destroy
Hello, l was hoping somebody could help with this problem. I have a player which when it collides with a box collider (trigger), it should add 1 to my counter and then destroy so the player can't interact with it anymore.
Comment
Answer by Positive7 · Aug 23, 2015 at 07:58 PM
Add this to Player :
using UnityEngine;
public class Something : MonoBehaviour {
public int counter;
void OnTriggerEnter(Collider other){
if(other.gameObject.tag == "Whatever"){
counter++;
Destroy(other);
}
}
}
Your answer
Follow this Question
Related Questions
I can't get 2DCollider to work. 1 Answer
Weird behaviour with OnTriggerEnter 0 Answers
Ideas for detecting collision speed with trigger? 2 Answers
Collider not working... 0 Answers
Trigger collider information 3 Answers