- Home /
Trigger 2d detect other gameobject and avoid me
Hey guys. I need some help about triggers 2d. I have a ball who cast a spell around it. spell collision is type trigger 2d. I want to detect other players in trigger 2d and avoid to detect me... Now i have this code who detect only me... My ball have name : "Me"; And the other balls on the scene have name : "Enemy"; This is the code for detect and substract 10 from my hp;
void OnTriggerEnter2D (Collider2D collision)
{
GameObject hit;
hit = collision.gameObject;
FootballHealth health = hit.GetComponent<FootballHealth>();
if(health != null)
{
health.TakeDamage(10);
}
}
Your answer

Follow this Question
Related Questions
How do I have an object ignore collisions with one collider in an object but not a second one 1 Answer
gameobject.findwithtag not working to all objects 1 Answer
Two colliders in one Game Object, one is trigger. How to change size of both? 1 Answer
Why is my OnTriggerEnter2D(Collision2D other) function not working ?... 3 Answers
How to make a collider be is trigger to some certain layers but be normal to others? 2 Answers