OnTriggerEnter conflict

So I have a 2 Agents. Agent 1 is shooting at agent 2. The bullet is a trigger and the agent has a collider. I have a bulletController script and a AgentController.

My problem:

If one agent hits the other with a bullet I get NullReferenceException, because in the agents script I have a OnTriggerEnter and I look there if the bullet hits. But the agent doesn’t have a trigger. So would it work if I set the method to onCollisionEnter, even if the bullet is a trigger? How can I solve this? But I do not want to place the Ontriggerenter to the bullet script.

Hello!

You are little bit copnfused :smiley: (its normal collides are confusing sometimes)

First, i recommend you to spend 30 minutes reading the Unity Manuals

And all its variants (enter, stay, exit, trigger, collision…)

I’m sure you will find some sentence that will make you realize something you didnt know or didnt understood.

Then, i think best solution is to make the bullet a trigger collider, and only detect from inside the bullet if the triigerEnters some collider with tag enemy or player or something like this.

Bye!