- Home /
I need help with triggers
I am making a game that has lava and I am using onTriggerEnter. but I need to detect witch trigger is touching the lava Here is my code
void OnTriggerEnter (Collider other) { if (other.gameObject.tag == "Lava" && other.gameObject.CompareTag("player lava trigger")) { touchingLava = true; } }
Answer by Ikariwara · Nov 30, 2017 at 09:44 PM
The lava object should be the trigger rather than having a trigger on the player, or you can detect which tagged gameobject the player is colliding with and apply damage for different tags, also try to name tags with one word only.
Example: private void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag == "lava") { //Apply damage } } This method should be on the player
Hope this helps!
Your answer
Follow this Question
Related Questions
Destory/Collect object to open door 1 Answer
Return gameobject from a TriggerEvent. 1 Answer
Trigger not getting GameObject 2 Answers
Rigidbody.SweepTest Hit Trigger Colliders 0 Answers
Can requirecomponent specify IsTrigger on a collider? 1 Answer