Weird collision result in grid based movement

Hi, guys. Please download and run the app and see. Any idea what is causing the issue?

I have set the collision mask exactly to the size of each sprite, a 64 x 64 sprite has a 64 x 64 collision mask, a 64 x 128 has a collision mask of 64 x 128. But the randomly moving object seems to get stuck sometimes when collided with other object, overlap even. (9.24 KB)

This happens because you use the actions to separate the npc from the obstacles, and then move the npc, the scene is rendered after the last event so if the npc move over an obstacle it will be drawn overlapping it and fixed at the beginning of the next frame.

Move the events to separate the object from obstacles after moving the npc :slight_smile:

Hi again, Lizard. Great tip! It’s working now! But did you notice that the player cannot be moved? The player cannot be control once I center the camera on the player object. Why is that? If I don’t center the camera on the object, everything works just fine.

Mmmh, ok, some things:

  • The player has the top-down and platformer behavior at the same time. They can’t work together but there is no event deactivating one of them.
  • The top-down behavior has the default controls disabled, and there are no events to simulate controls.
  • There’s no action to center the camera on the player.

With such problems the player should not move at all, so I think you’ve already fixed all the points above, it’s hard to help you with a different project than yours :wink:

Now the camera problem, this (probably, not sure what you’re doing) happens because you’re centering the “Char” layer camera only, so the player is actually moving, but the world in the background is rendered in a static position (note how the npc moves in the opposite direction you’re trying to move, because both the player and npc are in the same layer and you’re moving).
To fix it center the “Map” layer on the player too :slight_smile: