Unsolved Collision Problem

0 favourites
  • 7 posts
  • Hi!

    So... I've had this ongoing collision problem where if an enemy is jumping/moving upwards, and the player is falling, the player will be damaged sometimes instead of damaging enemy.

    I'm pretty sure it's because of the speed of both the enemy and the player. They are both moving too fast on collision for the game to register it. I've tried changing the condition from [on collision with another object] to [when overlapping with another object], but the problem persists.

    Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It would help if you could share your project file or a screenshot of your event sheet.

    If collision is not registered, objects must be moving very fast and be quite small.

    Say, if two sprites 100px wide are moving towards each other, their combined speed should be 3000-6000px/sec or more.

    You can make a simple event to check that the collision is indeed not registered:

    Sprite1 on collision with Sprite2 -> Browser log "collision"

    If this is really the case, try increasing their size by pinning a bigger collision box (invisible sprite) to them. You can only use it to detect collisions while objects are in the air and moving very fast.

  • It would help if you could share your project file or a screenshot of your event sheet.

    If collision is not registered at 60 FPS, objects must be moving very fast and be quite small.

    Make a simple event to check that the collision is indeed not registered:

    Sprite1 on collision with Sprite2 -> Browser log "collision"

    If this is really the case, try increasing their size by pinning a bigger collision box (invisible sprite) to them. You can only use it to detect collisions while objects are in the air and moving very fast.

    Thanks for that info. I tried to replicate the issue on a test capx, but it's not happening. not sure why.

  • It would help if you could share your project file or a screenshot of your event sheet.

    If collision is not registered, objects must be moving very fast and be quite small.

    Say, if two sprites 100px wide are moving towards each other, their combined speed should be 3000-6000px/sec or more.

    You can make a simple event to check that the collision is indeed not registered:

    Sprite1 on collision with Sprite2 -> Browser log "collision"

    If this is really the case, try increasing their size by pinning a bigger collision box (invisible sprite) to them. You can only use it to detect collisions while objects are in the air and moving very fast.

    I didn't notice that you edited your post... Player is 32X32, and most enemies are 32X32. Player has fall speed of 800(but is sometimes faster due to powerups). I have different enemies, some that jump, some that move up and down, but all of which sometimes give me this problem.

    Anyway here is a picture of event sheet: https://www.dropbox.com/s/36zv2isvjjdpu ... n.png?dl=0

  • Then yes, collision probably happens between the frames.

    I would pin another invisible box to the player ("PlayerFallingBox"), the same width as PlayerBox, but 3 times higher.

    And use it to detect collisions with enemies when the player is falling.

  • Then yes, collision probably happens between the frames.

    I would pin another invisible box to the player ("PlayerFallingBox"), the same width as PlayerBox, but 3 times higher.

    And use it to detect collisions with enemies when the player is falling.

    I'm not really sure what you mean by this... If you could make some example events and screenshot it that would help!

  • So your PlayerBox sprite is 32x32px.

    Create a new sprite, size 50x100, name it PlayerFallingBox. Add Pin behavior. Make it invisible.

    On start of layout set its position to PlayerBox and pin it to PlayerBox.

    Change your event to something like this:

    PlayerFallingBox on collision with Enemy

    (and) PlayerBox is Falling

    (and) PlayerBox.y<Enemy.y -> Subtract 1 from Health

    So this bigger PlayerFallingBox sprite will only be used to detect collisions when the player is falling.

    In all other events continue to use PlayerBox.

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