How do I detect if the player is touching the floor without the platformer behavior?

0 favourites
  • 2 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • hello, i am trying to make this phisics based 2D platformer that you are a little ball and you roll arround to move. all the code is using the phisics behavior and aplying force and changing velocity arround. the only problem is i cant detect if the player is on the ground or not so i can tell if they are suposed to be able to jump. i tried puting the platform behavior just to detect ifim touching the floor but it broke the physics, and the only other solution i can think of is puting stuff a bit over the floor to detect if the player is touching it and there fore if it's touching the floor, but that would be really slow. does anyone know what i can do to solve this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A rough starting point could be something like this:

    Player overlaps wall

    X player overlaps wall at offset (0,-1)

    — set onGround to true

    Other ideas could be to sample points below the player for overlaps, or position other sprites around the player for overlap checks, or checking the length of a ray cast below the player, or maybe checking the physics contacts and see if any of them are roughly pointing up. The platform behavior detects of the player is on the ground at the same time as it pushes the object out of walls vertically, but with physics you’ll have to resort to one of the other ideas.

    There are probably other approaches too.

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