I started with the platformer template in Defold. I changed the tile size from 64x64 to 16x16. After doing this, the logic for collisions doesn’t work. I’m unsure which part of the code I should change.
This is the behavior I’m experiencing.
This problem can be replicated in the platformer example by decreasing the size of the collisions.
As I’m typing this, I see that this is a recommended topic. However when playing the game, I’m running into the same issue — the player can spam jump next to a wall and suspend themselves in midair.
...
if normal.y < normal_threshold and normal.y > -normal_threshold then
normal.y = 0
end
if normal.x < normal_threshold and normal.x > -normal_threshold then
normal.x = 0
end
The platformer tutorial, from the Defold splash menu, didn’t have lines 152 - 157. It still worked, but there were complications when changing the collision sizes.
I also added the “if not self.wall_contact” as seen below, as I continued to have problems when adjusting gravity, jump speed, etc.
local function walk(self, direction)
if self.ground_contact then
self.velocity.x = max_speed * direction
else
if not self.wall_contact then
-- move slower in the air
self.velocity.x = max_speed * air_acceleration_factor * direction
end
end