Pin + Custom Movement + Overlap event = Bug

Bugs will be moved here once resolved.

Post » Tue Jan 27, 2015 8:27 pm

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
You do not have the required permissions to view the files attached to this post.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Fri Jan 30, 2015 2:55 pm

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.
Scirra Founder
B
402
S
238
G
89
Posts: 24,644
Reputation: 196,095

Post » Tue Feb 03, 2015 1:35 pm

@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.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests