Collision problem / explanation

Hello guys, i need simple explanation about how collisions work cause i dont get it properly probably.

I created object with collision (lets call itenemy move controller’) for my enemy(AI), it makes my enemy controller smarter so he can detect a collisions in front of him, and therefore he knows when to stop or when to move.

Although, for some reason this collision attached on enemy cannot detect collisions of the traps, he though can detect my player controller collision. I was curious and i tried to ask the trap collision if he collides with the enemy move controller collision, output was true, so even my trap collision could detect the enemy move controller. When no rigidbody attached on enemy move ctrlr, it can detect player controllers collision and trap can detect enemy m. c., however enemy m. c. cannot see trap.

  • here is simple collision script which should detect any collision he enter, with output in console

  • trap collision is created by script

  • This script creates a collision which follows animation bone

Somebody, any advice on this?

I also played around with rigidbodies but didnt get the result I want.

An entity that has a collision but no rigidbody is a trigger. Triggers can’t detect other triggers.

I don’t know if your traps are triggers or have rigidbodies. If they are triggers then that would explain the issue you are having

1 Like

Thank you for fast response, @yaustar.

Yes, traps dont have rigidbodies, they are only triggers.
But i also tried to put kinematic rigidbody on my enemy move controller, no succes.

Should I instead of triggerenter use collisionstart?

Yes, when a rigidbody enters a trigger, trigger events are fired on the collision component of the trigger entity, not collision events

1 Like

So, i changed the code


It still cant see trap, it only see player as before.

The collision component of the trigger entity gets the trigger events, not the controller’s rigidbody.

Edit: Correction, both the rigidboy of the controller and collision component of the trigger get the trigger events according to the documentation:

So kinematic rigidbody with ontriggerenter script attached on should detect a trigger ?

I tried to put collision start on enemy move controller first, and then i switched it with trap and put collision start there, but no result.

So trap as “trigger volume” could detect other “trigger volume” which was enemy move controller, but it was not working vice versa

And enemy move controller “trigger volume” could not detect my player which has kinematic rigidbody attached on

  • now i see it doesnt detect player with kinematic rigid.

Here’s a quick example of kinematic object moving into a trigger:

You can see the event listener here on the cube that is move:

1 Like

Well so I dont understand, because i have it set up the same. My enemy move controller has kinematic rigidbody with event listener, and triggers with non rigidbody object using the collision, when enemy collides with trap, he dies and is being respawned, he as well has kinematic rigidbody so as my enemy move collider has, but for whatever reason its not detected

You may want to try to isolate the issue but creating a small test case and see if you can narrow down the problem.

Using the ‘render physics’ scripts from before may also help.

It seem that i fixed the problem, i had to add kinematic rigidbody with script as well on the trap object (where i create collision), but also change in both scripts to collisionstart, and now it detects the object. Thank you for you assistance! :sunny:

Anyway, when i try to define collision end, am i doing all the same as when defining collisionstart ?



EDIT: found a documentation, there has to be other instead of result, so the condition line would be looking like this: if(other.tags.has('trap')) {}

It can be named whatever, it is just a variable name that you define yourself:

1 Like

Well, it didnt work when i kept result as variable