Trigger response is... not doing anything? (SOLVED)

So, um…
I have written some code for detecting collision (because I don’t want to use the other collision system, I have things planned for not using that), however, the triggers are not working…? I have code here if anyone wants to look at it:

if message_id == hash("trigger_response") then
		if message.other_group == hash("wall") then
			if message.enter then
				if message.own_group == hash("up") then
					wall_up = true
					print("wall_up")
				end
				if message.own_group == hash("left") then
					wall_left = true
					print("wall_left")
				end
				if message.own_group == hash("right") then
					wall_right = true
					print("wall_right")
				end
				if message.own_group == hash("down") then
					wall_down = true
					print("wall_down")
				end
			else
				if message.own_group == hash("up") then
					wall_up = false
					print("wall_up_leave")
				end
				if message.own_group == hash("left") then
					wall_left = false
					print("wall_left_leave")
				end
				if message.own_group == hash("right") then
					wall_right = false
					print("wall_right_leave")
				end
				if message.own_group == hash("down") then
					wall_down = false
					print("wall_down_leave")
				end
			end
		end
	end

Any help would be appreciated~

Did you start with print()s at the top level (under if message_id == hash("trigger_response") then) and work your way down?

4 Likes

Upload a minimal sample project where it is not working.

Make sure your masking groups are set correctly.

2 Likes

Hope you can fix this quickly. Setting up the groups and masks and types etc. is a little complicated at first but once you’ve got it right it will be great. your code looks good to me, although I am not an expert so my advice would be that you look into how the collision objects are set up.

2 Likes

That explains a lot. Thanks for the help~

1 Like

Okay, nevermind after 8 days because I was working on other things, but


I set the masks, and there’s no trigger response?
I put print functions under the trigger response, and I’m getting nothing…?

Is the script attached to the correct game object?

I often start by adding

print(message_id)
pprint(message)

…to the on_message() function to see if there’s any messages getting to it at all and what’s in them.

2 Likes

Yes, the script is connected to the correct game object (the game object receives input in the form of a message and I tested your method), however, I’m still not receiving a trigger response.

I tried putting a print message in the on_message() function and within the trigger_response, it turns out that I’m not getting anything from the trigger_response.

Please upload a .zip of your project and I will have a look at it for you.

…I think it’s a bit too big to put it here? Is 19.5 MB (in a zip) too much?
It won’t upload.

Make sure to remove .git, .internal and build folders.

Emm… I’m starting to think it’s a problem with my computer. I may have to send it over by email or something?

(Maybe send it by messages?)

Share it with me (bjorn@defold.se).

Will do~

Thanks, I got the project, but it won’t build:

19

One thing to consider if collisions aren’t working is that the collision objects must belong to the same collection/world. More info: https://defold.com/manuals/physics/#caveats-and-common-issues

1 Like

That makes a lot more sense. Thank you~