[SOLVED] Collision not detected

Hello guys, i’m new here and trying to learn the engine by doing a snake game, but i’m having trouble with my collision function.

I’m doing the same thing as this tutorial (https://developer.playcanvas.com/en/tutorials/collision-and-triggers/) but the function isn’t created, and i used a debug log message on initialized function and the script is working, i know this must be something easy to solve, but i tried and searched everything about.

My entity has a collision asset.

If someone can help me, i will be gratefull!

link to my project:https://playcanvas.com/editor/project/727476

Hi @FernandoIM,
It seems that the Box entity you have doesnt seem to have a rigidbody component which is needed for collisionstart to work, if you dont want to add the rigidbody component you could use the triggerenter event instead

1 Like

So, i tried with rigid body before, but after u said, i’m trying with collision and rigid body on my player, and only collision on the entity i want to be a trigger.

some prints

print1

A few things here:

Collision events are only fired when two rigidbodies collide. In this case where you have a rigidbody and a trigger, only trigger events are fired on the trigger entity.

I’ve fixed up the project here: https://playcanvas.com/editor/scene/1010936

Thank you for the help, i fixed the event to trigger like you did.

I’ve tried this setups before, but now i think my mistaken was in my rigid body type, i was using static all the time, now i need to learn about each type and how/when to use then.

Thank you everyone!

Oh, FYI, I fixed the camera as it was rendering in a weird way. You had the near and far clip values flipped so the near plane was further away than the far plane