Multiple collision rectangles?

0 favourites
  • 4 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • I've got a game where the player is driving down the road, and I'd like a collision to fire if he goes offroad to either the left or the right (so I can have the car crash). The problem is that as far as I can see you can't have multiple collision polygons for a sprite. I tried setting the road as the collision poly and getting the inverse (so it triggers when the car is not colliding with the road), but then the car shows as on the road as long as even the tiniest bit of the car is touching the edge of the road, even if the rest of the car is off road. Is there anyway around this, or do I have to create 2 invisible sprites to the left and the right of the road, which seems kind of wasteful for something like this. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Rather than a single sprite, break your road into instances border-surface-border, where surface is where your car is supposed to drive, and handle the collision on border.

  • So I'd need to have 3 sprites, one for surface, and one for each of the borders?

  • You need two sprite objects.

    One for the surface, no collision there.

    One for the border with a collision polygon (or bounding box, depending on your design).

    Then you spawn 2 border instances around each side of a surface instance and you have your road. You can do it either in the editor or at runtime.

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