Multiple Collison objects On a Game Object

Hi all !

Im relatively new to Defold and I’m currently developing a platformer game. I have an enemy game object with a script file (attached below) and collision object. I’m trying to create a Goomba like enemy where if the player collides with the enemy GO head collision object the enemy GO will be eliminated.

Collection structure
defold 1

Enemy script file
skeletonMovements.script (2.9 KB)

My issue is that the enemy GO does not recognise a collision has taken place if in contact with the player GO. I’ve made sure the I’ve named the group and mask correctly and added a print message to trigger if a collision has taken place. I’ve tried having two collision objects on the same enemy and tried creating a child GO with a collision object( trigger type) off the parent enemy GO and neither have recognised a collision ( example below) and I’m not sure why.

Run time with physics debugger - Clear interception but no print message to console
head snippet

I hope I have been able to express my issue in a way that is understandable. Please let me know if you need more information.

Thank You

Your variable 'trigger_response' is never defined, so that condition will never be true. Just do print(message_id) and see what you get.

4 Likes

Thanks for your reply @ross.grams

I’m slightly confused what u mean by my trigger_responce variable is never defined

Like this?
tg
If so then then collision still is not recognised when the player contacts the ememy collision object.

Thanks.

In the skeletonMovements.script that you attached you had:

if message_id == trigger_response then

but you did not have:

local trigger_response = hash("trigger_response")

So the variable named trigger_response never existed.


Anyway, I guess that wasn’t the only issue.

There’s a bunch of different things that could be wrong. The easiest way to help you with this is if you zip up your project files (you can exclude the “build” folder) and post the zip here.

3 Likes

I have Attached my project and deleted the build folder like you said. Please let me know if u need any more information and thank you for your help

Defold Project 1.zip (2.0 MB)

Two things wrong:

  1. Wrong type - The “headCollision” component was Kinematic, not Trigger.
  2. Wrong group/mask - The “headCollision” component’s Group was set to “head”, but the collision component on the player did not have the “head” group in its Mask list.
5 Likes

I’ve made the corrections and the trigger collision is recognised :grin:

Thank you!

3 Likes