For example:
There is enemy which can be hit by a bullet,
so there is collider for that.
Now I need another collider for click ray casting in order to selecting/targeting enemy(target enemy).
(these colliders are in same place but select/target is larger (sphere colliders))
Logically there is a script (for bullet)
private void OnTriggerEnter(Collider col)
{
Enemy enemy = col.gameObject.GetComponent<Enemy>();
if(enemy!=null)
{
enemy.Health -= 1f;
Destroy(this.gameObject);
}
}
but if there is 1000 enemies
that means that it will check 1000 collisions for select(which do not mean anything to bullet)
and 1000 for enemy
So is there way to restrict these colliding by something(tag,layer…?)?
Or some other way is appreciated.