Collision Detection Not Working All The Time

  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • because this is one of C2 weakest points. Collision checks with it's own object type.

    Instead of On Collision. try OnOverlap.

  • 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.

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