Hey guys, so I’m trying to identify the location of a object collision relative to one of the game object. Both game objects have collision objects set to “Trigger”.
I added the code to one of the game objects under the on_message function, and, it doesn’t seem to be doing anything at all. Here’s what I got
function on_message(self, message_id, message, sender)
if message_id == hash("contact_point_response") then
print("It's just a scratch. I've had worse.")
end
end
But nothing showing up in the console. Any ideas what I’m doing wrong?
Thanks everyone!
The code looks fine. Have you set the group and mask fields for both collision objects?
They were both default so I just now set the group and mask of both game objects to “main”. Still no change.
Try setting the group and mask something like the following. Say you want a bat and ball to collide:
For ‘bat’ object
Group : bat
Mask : ball
For ‘ball’ object
Group : ball
Mask : bat
Nope, that didn’t make a change. Sorry
Sorry - I just spotted something with the code. Try:
if message_id == hash("trigger_response") then
So… trigger_response was what I was using to change the angle statically (eg: 'rotation = 180 - rotation" which makes the game object bounce" , but I needed more details about the locations of the sprites such as “position=…” so I can control the rotation based on where the collision happens. I’m trying to recreate Breakout from Atari and I am trying to make it so that when the ball hits closer to the edges of the paddle, it makes it fly more to the sides than straight up.
I’m currently trying out another way to achieve the same result which is by calculating what I need using the go.get() function which is used inside a trigger_response. Maybe that will work instead? 
(I’m going afk for a while also. Thanks for all the help!
)
From the docs:
contact_point_response
This message is sent when one of the colliding objects is Dynamic or Kinematic.
So you’ll never get that message if you’re just using triggers. I suggest you change your ball to a kinematic body. Then you’ll get the contact_point_response
message and you should be able to use the normal vector it gives you to figure out the bounce trajectory.
Ahhhhh! That’ll do it! Thanks a ton my friend!