Precise Collisons of Platformer

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • Hello all !

    While using the platformer behavior , I noticed that there is regularly a shift in the player's position relative to solid elements. It is very slight (less than 1 pixel) but enough to offset the player by 1 pixel. I have resolved this problem, its work good for now and if it can help somebody, it is certainly due to the floating numbers:

    But that doesn't work with the Tiles map. In fact my variable of collisions does not detect any collisions and so the same problem comeback. Do you think there is a possibility of detecting collisions of solid tiles with a variable ?

  • It is very slight (less than 1 pixel) but enough to offset the player by 1 pixel.

    It has always been like this. Platformer object floats slightly over the floor.

    There are two workarounds:

    1. Attach a separate invisible sprite used specifically as a collision mask. It could be 2px larger than your character, for example.

    2. Use "Is overlapping at offset" condition with 1-2 px offset, to check if the character is touching a solid object.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for your answer, but I don't think you are really understand this problem. I speak of horizontals collisions in X axis. A interval that is created randomly when the engine repositioning the player :

    I already used the function "Is overlapping at offset" my variable collX is there to check how work the collisions engine. Here my events :

    Used just the mask player is voluntary, I want to see and understand how work the platformer behavior without graphics.

    So if anyone know another solution, maybe more functional than mine or a solution for check collisions with solids tiles (with variable) I take it, bye !

  • The Platform behavior doesn’t allow an object to overlap with solids, doesn't matter if it’s a floor or a wall. When it collides with a solid, the object is pushed back until it’s no longer overlapping, so there's always a small gap.

    Directly changing X/Y values of the Platform object is not a good idea - you are messing with the behavior, not letting it to do its job.

    A common solution to collision issues is to use two sprites: one invisible sprite with the Platform behavior, and another visible sprite with the desired collision mask and animation. You can adjust the position of the visible sprite if needed.

  • Yes I understand what you are saying, but the problem is that the repositioning of the engine is inconstant. Placing sometimes in the wanted x or in other times offset by 1 px. The sprite draw who takes the same x and y of his mask will have the same problem. Except if as you say, it is repositioned on "bad collisions". I will do some test, but I have already do a clean collision, only with a mask in game maker for example or in lua.

    Anyway thanks for your explication and for your help !

  • The platform behavior resolves collisions incrementally instead of precisely using collision geometry. Incrementally means it works with something like:

    While overlappingSolid move out of solid by 0.1 pixels.

    It’s general purpose and works fine most of the time, but won’t give exact clean values as you’ve noticed.

    Modifying the position to clean up the values would likely conflict with what the behavior was doing in many cases.

    But that’s just some general thoughts.

  • Ok I see, as dop2000 said, the module platformer works with a system of ejection, surely every frame, when there is a collision. It's something I had to do to rectify the vertical moving platforms collissions with love2D. So I think you're right, altering this module will bring me more difficulty, but I will do certainly some other repositioning collisions test.

    But thanks to you, I isolated the problem while testing if the collision work less precisely and I move my draw sprite in this case. Indeed, It's work good graphically,

    Thanks you 2 !

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)