Collision Detection Not Working All The Time

Discussion and feedback on Construct 2

Post » Tue Dec 03, 2013 4:11 pm

I am trying to make a game where it will randomly place a few sprites on the screen. If any of the sprites collide/overlap they are moved to another location. This works most of the time, but there are a few times where the sprites end up on top of each other and don't get relocated.

Code Example:

Sprite1 on collision with Sprite1:
       Sprite1 Set position to (random(600), random(400))

From my understanding of the collision event, this will run each time there is a collision between any Sprite1. Why does sometimes it doesn't do it? Is there a better way of doing this type of collision detection?
B
2
Posts: 1
Reputation: 152

Post » Tue Dec 03, 2013 4:17 pm

because this is one of C2 weakest points. Collision checks with it's own object type.

Instead of On Collision. try OnOverlap.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,018

Post » Tue Dec 03, 2013 7:27 pm

I'd say that if sprites, that already triggered a collision in the same tick, land on top of each other after the repositioning(s), they won't trigger a collision again in the same event.

As jayderyu stated, checking for overlap would be an alternative.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests