Hello and happy new year to everybody!
I have a problem with the collision response, I have managed to successfully implement the one-way platform code provided by @britzl in the following post:
But, I have a problem I can not fix because I don’t understand very well the projection-contact-normal value that is used to calculate the collision point in the given
handle_geometry_contact
function
And I have two collateral products as seen in the following capture:
platform_fall.m4v (115.1 KB)
First, the hero falls correctly onto the lower platform,
Then (1) he goes up automatically when he encounters the higher platform,
And then (2) it falls from/through the following lower platform when he has just landed, like if the landing force would have been so strong that it made him go-through the platform…
I think it has something to do with the normal, but anyone knows how to fix this?
The code is exactly like the example given in the other post:
function on_message(self, message_id, message, sender)
if message_id == msg_contact_point_response then
-- check if we received a contact point message. One message for each contact point
if message.group == msg_group_ground then
handle_geometry_contact(self, message.normal, message.distance)
elseif message.group == msg_group_abyss then
-- we have fallen into the abyss, reset position
go.set_position(self.position)
elseif message.group == msg_group_platform then
-- If the message normal is pointing up and we didn't have
-- platform contact from below last frame then we have fallen on top
-- of a platform and need to treat it like geometry contact
-- Any other contact with "platform" is considered as contact where the
-- player is passing through the platform from below
if message.normal.y > 0 then
if not self.platform_contact_from_below_last_frame then
handle_geometry_contact(self, message.normal, message.distance)
self.platform_contact_from_below = false
else
self.platform_contact_from_below = true
end
else
self.platform_contact_from_below = true
end
end
end
end
EDIT: I forgot to mention that the falling through the platform happens even if the hero is running steadily on the platform, as you can see in the following post.
Thank you in advance!