Author Topic: v1.27 - FlxCore.collide bug?  (Read 1619 times)

Sean

  • Guest
v1.27 - FlxCore.collide bug?
« on: Sun, Nov 29, 2009 »
I think there's an issue with the new collision function.  Assume two sprites sit side by side against one another.  Then they simultaneously move to the right with the right sprite moving faster than the left.  This should not cause a collision, but since the bounds are based on both the current and last positions, this is considered a collision!  Not only that, since the left sprite is slower than the right, it assumes the right sprite collided with the left and moves the left sprite to the right side.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: v1.27 - FlxCore.collide bug?
« Reply #1 on: Mon, Nov 30, 2009 »
To clarify the steps here:

1 - check to see which sprite is moving faster and in what direction

2 - the right sprite is moving to the right faster than the left sprite is moving to the right

3 - what we want to know is if the faster moving sprite caught up with and hit the slower moving sprite

4 - currently we do that by just checking if the boxes overlap along that dimension??

5 - so probably the algorithm should be adjusted to take the starting positions into closer account?

sry it is late here, I am mostly making notes for my own good so I can try and correct this, as it should lead to better overall collision behavior across the board, thanks for pointing it out!

Sean

  • Guest
Re: v1.27 - FlxCore.collide bug?
« Reply #2 on: Tue, Dec 1, 2009 »
Yeah I think you've got the idea.  As long as the sprite on the left moves slower to the right than the sprite on the right, you'll get a collision that pushes the left sprite to the other side.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: v1.27 - FlxCore.collide bug?
« Reply #3 on: Thu, Dec 10, 2009 »
Hey Sean, thanks again for finding this.  I redid the collision logic to hopefully be more axis-independent AND to account for this odd behavior - if you have any way of testing it (or anybody else does for that matter) that would be awesome, i'm moving on to other things!