Pin + Custom Movement + Overlap event = Bug

0 favourites
  • 3 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Problem Description

    We have three sprites, "Anchor", "Field", and "Arrow".

    Pin Field to Anchor. Arrow we control through 8-direction movement. If Arrow overlaps Field, Field changes color (by changing animation frame, but that's not important)

    Accelerate Anchor and Arrow identically to the right using custom movement. Get them up to about 1000 pixels/sec to make the effect very obvious. Field stays with anchor perfectly, as does Arrow. Now use 8-direction to move Arrow toward Field. If you approach from the left of Field, Field will change color before Arrow actually overlaps Field! Approach from the right, and Field won't change until well after Arrow has overlapped. It is as if the overlap collision is getting checked after Field has moved on due to the pin.

    Attach a Capx

    Done.

    Description of Capx

    The .capx does exactly what is described above in order to illustrate the bug. It also has walls that demonstrate that pinned solids work correctly in this scenario as long as Arrow has 8-direction listed before Custom movement in it's list of behaviors. (Note that if Custom movement is listed first, you get a solid collision bug similar to the overlap collision bug).

    Steps to Reproduce Bug

    • Step 1 Hold the space bar down to accelerate Anchor(the purple square) and Arrow(the red triangle) to somewhere around 1000 px/s.
    • Step 2 Move Arrow around using arrow keys. Make Arrow overlap Field (the blue-green rectangle) from different directions.
    • Step 3 Observe the results.

    Observed Result

    Overlap condition works as expected when there is no custom movement. Overlap collision detection "lags" behind while the pinned sprite is moving.

    Expected Result

    Overlap collision detection should function the same whether the sprites are moving or not.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (Tries, but shows black screen with HTML5)

    Operating System and Service Pack

    Windows7 64bit Home, SP1

    Construct 2 Version ID

    Release 195 64bit/Steam

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Closing as won't fix: this is just because the behaviors update their positions at different stages within the tick. In particular the Pin behavior updates object positions at the end of the tick, so your overlap event is always testing the latest player position with the previous tick's position for objects with the Pin behavior, so it's always testing it at speed x dt pixels behind where it appears. The overlap condition is actually working correctly.

    The easiest workaround is not to rely on behaviors and position everything with events, so you can control the exact sequence of position updates and collision tests. We can't change the behaviors since that will break other games.

  • Ashley Thanks for the explanation. I did find a workaround though. If you add the custom movement behavior to the Field and accelerate it simultaneously with the Anchor, everything works out. That way I don't have to reinvent the wheel so much.

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