When collisions fail.

0 favourites
  • 4 posts
  • Sometimes when a bullet clearly is on collision course with an enemy, the collision never registers.

    I presume it's because of the bullet - and enemy speed, making the collision never happen since the bullet and enemy simple pass each other during a tick.

    Is there a workaround that doesn't involve lowering bullet speed?

  • Yes, if you make the bullet move via a loop, you can check the collision inside the loop, which can be a lot faster

    Eg:

    Repeat 5 times

    (action) Bullet move 1 pixel

    (sub) On collision

    (action) Destroy bullet

    Here the bullet moves 5 pixels per tick, and the collision is checked 5 times per tick. Note this will cause a performance hit if you have too many bullets

  • Ah, thanks. Makes sense.

    I managed to implement it somewhat successful. I still have bullets passing through enemies, apparently not as many, though.

    So in order to understand what's going on, I have a question: By what conditions is a collision tested?

    If a bullet collides with an enemy within the repeating pattern (say at 5th repetition out of 10), does that count as a collision? Because of this was the case, moving the bullet 1 pixel would always ensure a collision, right?

    The reason I'm asking is because that's exactly what I've done, then tweak the bullet speed with the amount of repetitions per tick, but as I wrote before, there's still stray bullets.

    Would enlarging enemy hitboxes help?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use CustomMovement instead of Bullet for fast moving objects. Use the 'On CustomMovement step' trigger to check for collisions every step and adjust the 'pixels per step' setting to increase accuracy. With 'pixels per step' set to 1 you can check for collisions every pixel (though that would be overkill in most cases).

    customMovementBullet.capx (r108.2)

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