I am working on a 2D RPG. Right now, im trying to sort out interactions between the player and it environment (collisions) and I am having trouble with kinematic collisions. When the players collider meets with the environments (a rock) collider, they get stuck on each other. I know that the common way to fix this is to resolve the collision with some code but im a very new coder and have no clue how to do that. I decided to check out the RPG map sample, and it uses this chunk of code for its collisions:
elseif message_id == hash("contact_point_response") then
-- simple collision solver
local proj = vmath.dot(self.correction, message.normal)
local comp = (message.distance - proj) * message.normal
self.correction = self.correction + comp
go.set_position(go.get_position() + comp)
end
end
This code doesn’t work for me and I don’t know why, or if it would even work in the first place. Can anyone help me with my issue?