Player falls through floor (SOLVED)

Hi, I’m having an issue with collision objects.
The main collection contains a floor , and a player with a script which handles an “8 ways movement” logic as seen is https://www.defold.com/examples/input/move/ (script is quite similar, only “left” and “right” movements are allowed).
The only way to allow the player to naturally fall on the ground, and to stay there without falling off, is to setting the floor’s collision object to “STATIC”, and the player’s one to “DINAMIC”. But that settings won’t allow me to control the player through keyboard (the player will stay there, still and frozen; I used some “print()” functions around the code to check if it’s run, and it is, but the player doesn’t move).

The only way to be able to move the player though keys, is to set the player’s collision object to “KINEMATIC” and the floor to “STATIC”, but by doing so, the player will have no gravity on it! And I would be able to let it go through the floor.

I tried to build the project using the physics debug (in game.project),
I made sure the collision boxes were big enough,
and found out that when player (KINEMATIC) and floor (STATIC) overlap, the debug shows two arrows pointing up. I’m not sure what they mean.

Another hack I tried to use was trying to set the floor as DYNAMIC and the player as KINEMATIC. The 8 ways movement works, and there is collision between the two objects, but this method fails miserably because the floor must have a mass greater than 0, without which the floor will fall off too.

I applied the collision objects exactly as shown in one of the old official tutorials (the frog running)// delete thread.
Using Editor 2.
What did I do wrong?
Thanks for the help.

If you had a problem and found a solution on your own you should share the solution so people in the future can search to find it too.

2 Likes

Here I’m posting the issue again :confused:
I didn’t find a solution on my own, if I did I would obviously share it.
I just lost hope on fixing it last night ahah :smile:
Hope I didn’t violate the forum’s conduct rules.

1 Like

Kinematic collisions don’t react to collisions on their own, so you might need to play around with collisions in your scripts a little.
You can always refer to these: -
Platformer tutorial or Runner
on how to resolve kinematic collisions and respond to it.
Also, for kinematic collisions, we need to apply gravity in the scripts using vectors.

There’s no need for losing hope. This topic is slightly confusing for beginners but as you learn Defold, believe me, you’re gonna love it.

Fixed :smile:
the player’s game object needed some lines of code for handling geometric contact.
Thanks

1 Like

Can you share the code? I followed the platformer tutorial and the character sometimes falls through the floor…?