- Home /
OTHER object when using OnTriggerEnter2D
Hey, I want to find out the name/layer/tag of the object which activated my trigger. I have two types of bullets. When my Player is hit I want to find out which bullet hit him. Is there any way to do this?
Thank you very much :)
Comment
Answer by highpockets · May 02, 2020 at 01:51 PM
If the script is on the player, this should do the trick:
void OnTriggerEnter(Collider other){
if(other.transform.tag == “armourPiercingBullet”){
// armour piercing bullet code
}
if(other.transform.tag == “fireBullet”){
// fire bullet code
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612233021im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
OnTriggerStay2D Breaks When Adding AnimationController 1 Answer
Collision returning an error 0 Answers
Trigger versus collision? 2 Answers
Collision with renderer.enabled? 0 Answers
why isn't my OnTriggerEnter2D() function working? 14 Answers