Multiple collision rectangles?

Get help using Construct 2

Post » Sun Jan 15, 2012 11:22 pm

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!
B
7
S
2
G
4
Posts: 5
Reputation: 2,676

Post » Sun Jan 15, 2012 11:53 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Jan 15, 2012 11:57 pm

So I'd need to have 3 sprites, one for surface, and one for each of the borders?
B
7
S
2
G
4
Posts: 5
Reputation: 2,676

Post » Mon Jan 16, 2012 12:31 am

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791


Return to How do I....?

Who is online

Users browsing this forum: Kagubro and 32 guests