How do I check if an object is not overlapping an angled tiled background at a point?

0 favourites
  • 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I'm struggling to explain this well so I have included an image to help explain:

    So I'm using tiled backgrounds for collision boxes in my game. I know they're not ideal for more complicated collision detection, but 95% of the surfaces in my game are flat rectangles, so normally this will work fine.

    I do want to use some 45 degree angled slopes though, and this is where we run into a problem. Collisions still work fine, but I run a check for a certain function that determines if a player can do something based on if they're Y position is greater than the tiled background they're on top of. If the tiled background is not angled, then it works fine, but if it's angled of course then the player can be below the tiled background's Y while still being on top of it.

    I'm sure there is some math I could do to figure out if the player is above the object based on their X position and the angle of tiled background they're on top of, but I am having trouble figuring that math out.

    I'm also sure there is a seemingly simpler way to do this that does not involve a math check, but I'd rather not go that route due to the complexity of associated systems.

  • I understand the picture, but don't understand your question.. If you need to know the top Y coordinate of the tiled background object (green dot on your image), you can use BBoxTop expression.

    To detect if the player is on a slope, you can try "overlapping at offset". Say, if it's overlapping the ground at (-2,1), but not overlapping at (2,1), then it has a slope on the left.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply!

    In this case BBoxtop is going to give me the same result as Y, so those could be interchangeable. The origin is the top-left of the Tiled Background, so regardless of angle both will be the same. The image is just to show how I currently check if the player is on top of the tiled background, and how that doesn't work if the object is angled.

    I did consider your approach of using "overlap at offset", but for reasons that are too long winded to get into here, that's not an option. Asumme that the player object we need to check for is possibly always overlapping the tiled background, and is large enough that we need to be checking a specific point rather than the collision data of the player object.

    Now, the easy way to do this of course would be to pin a single pixel object to the player at the correct relative location for the check, and if I have to I will do just that. But I'd really rather not as my player objects already have a lot of pinned objects I am keeping track of, and because my player objects are also enemy objects there are a lot of them in each layout, so adding this overlap checker object can add a lot more objects to the layout.

    I'd really rather use some math on the check to determine if the relative point is empty or not in other words.

  • So you need to know if the object is on the ground (horizontal or angled)?

    Instead of the 1px pinned object you can define an image point and use System condition Pick Ground by overlapping point Object.ImagePointX("name"), Object.ImagePointY("name")

  • Oh wow, I don't know how I never noticed that picking condition before! I have a lot of animations I will have to set up that image point for, but that's minor, I think this will work, thank you!

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