my bullet:
- There is a Box collider (checked "is Trigger")
- It has Rigidbody2D (Gravity = 0, freeze rotation Z)
https://i.sstatic.net/ik1IY.jpg
I added the "OnTriggerEnter2D" function because isTrigger is checked. Bullet script:
private float lifeTime = 1.0f;
private void Start()
{
Destroy(gameObject, lifeTime);
}
private void OnTriggerEnter2D(Collider2D collision)
{
GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity);
Destroy(effect, 0.2f);
Destroy(gameObject);
}
When I fire, the OnTriggerEnter2D function works even though there is no collider/object in the direction of the bullet. It only works a certain distance away from my main character, and it's always the same no matter which direction I shoot.