Player (Kinematic) falling trough the floor (Static) (SOLVED)

My player object that has a collisionbox that is set to kinematic if falling trough my floor object that is set to static. Have been looking around the forum and have set the mask of floor and group of player to “player” and the mask of player and group of floor to “geometry” as I saw that was recommended to do but it still doesn’t work. I have seen that many people just got linked the platformer/runner tutorial but I have been inspecting that tutorial and haven’t figured out how to do this. I’m a beginner so please understand that :slight_smile: Thanks!

If the player is kinematic it means that it is part of the physics simulation in terms of collision checks. It is, as you’ve already discovered, not affected by gravity, and while collisions are detected they are not resolved. If you want to separate the player from the thing it collides with you need to do that yourself. Something like this (typed on phone):

function on_message(self, message_id, message, sender)
  if message_id == hash("contact_point_response") then
    local pos = go.get_position()
    pos = pos + message.normal * message.distance
    go.set_position(pos)
  end
end
1 Like

What kind of game are you trying to create? A platformer?

@britzl Well, yeah, a platformer for now to begin with and then adding my unique mechanics later.

That was it, only it should be message.normal * message.distance. Yeah, right now I’m just learning and probably asking a ton of questions on the forum but I try to do some research myself first. Thank you.

Edit: This does work, but makes it so when the player touches any collider (obstacle in game) it gets stuck to it unable to move anymore. For anyone else having this problem in the future: Read https://defold.com/manuals/physics/ there is a whole sector about " Resolving kinematic collisions" check it out, there is also working code with explanations.

Ah, yes thanks. Updated my answer.

What I proposed is the most basic collision resolution. If you have multiple collision contacts in a frame you may need to do a more advanced collision resolution.

Exactly, solved that as well. Updated the answer to say how I solved the issue

1 Like

Yeah, I forgot we had a section about that in the manual!