How do I determine if an object is hitting a wall/ground?

0 favourites
  • 3 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Using the physics behavior , how can I determine whether or not the player is hitting the side of object, or the top of the same object? I want to have the player take damage when he hits the floor or the top of an object, but not the sides. If you were wondering, the character is a physics rag-doll, and is completely controlled by the physics behavior, so i need to operate within the physics behavior. Is there any way? I can elaborate if asked, or post a .capx if needed.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, you can do that in two different ways.

    If the player is overlapping the object you can compare player coordinates with the object coordinates and with this determine if the player is by the side of the object or above it or whatever.

    However doing this requires a lot of testing and your game my get little buggy depending on the size of the sprites and speed they're moving.

    The other way is to create invisible and objects and attach them to the visible object. Note that these invisible objects should be smaller than the first one, and they should be at least 1 or 2 pixels beyond the are of the visible one.

    So you will check the player collisions to the invisible objects instead of the visible one. If the player collides with the invisible object attached to the left side of the visible one... then the player is colliding on the left.

    This will make your codding easier and the game will run smoothly and with less bugs, whoever creating too many objects on a single layout will slow down your game performance

  • Thank you, I never considered that. I was busy trying to think of something I could do strictly with coding, I really appreciate it.

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