C2 save/load system forgets disabled Physics collisions?

Report Construct 2 bugs here.

Post » Thu Oct 12, 2017 8:16 am

Problem Description

Overview
The native C2 save/load system appears to forget the "disabled collisions" state of Physics objects.
After loading, all Physics collisions are enabled regardless of prior state.

Details
The Physics behavior has an option to "Disable Collisions" between objects, on an object-by-object basis.
I'll refer to the data structure that stores that inter-object collision info, as the "collision relationships list".

e.g. Given SpriteA, SpriteB, and SpriteC, you could disable collisions between only SpriteA and SpriteC.
All other collision combinations would still occur normally.


When using the native C2 save/load system, if you save, and then load, the Physics behavior's "collision relationships list" state is not restored.
After loading, all collision relationships are set to enabled.



Attach a Capx
https://www.dropbox.com/s/jpvaro62rvj8t81/fi_demo_Physics_DisabledCollisionsForgottenOnSaveLoad.capx?dl=1



Description of Capx
Image of the capx.
Image

The capx shows a real-time interactive demo of the problem.
There's text in the capx to explain steps to execute and what to look for.

The capx shows two physics enabled sprite objects, a static (Immovable) Orange box, and a moving Blue box.
The moving blue box is attracted to the Red "X" which drags it back and forth in a horizontal sine motion.
On layout start, collisions between the blue mover box and orange static box are disabled.
This allows the blue mover box to pass through the static orange box without colliding.
At the bottom of the canvas are 5 buttons.
  • Save: Save game state via native C2 save/load system.
  • Load: Load game state via native C2 save/load system.
  • Set no-hit: Disables collisions between Mover & Static.
  • Restart: Restarts layout.
  • Toggle text: Show/Hide text.



Steps to Reproduce Bug
Run the capx.
  1. Observe the blue box passing through the orange box without colliding.
    This is due to the event: On start, disable collisions between those objects.
  2. Click the "Save" button, to save the game via C2's native save/load system.
  3. Click the "Load" button, to load the last save state.
  4. Observe the blue box now collides with the orange box.

    The disabled collision state has not been restored.

You can optionally experiment a little further:
  1. Click the "Set no-hit" button to re-disable collisions.
  2. Observe, the boxes no longer collide.
  3. Retry clicking the "Save" and then "Load" buttons.
  4. The boxes now collide again.



Observed Result
The Physics behavior's "collision relationships list" is not restored after loading the game state, and so the boxes begin colliding with each other.
Image



Expected Result
The "collision relationships list" is restored after loading the game state, the disabled collision status between the boxes is likewise restored. and so the boxes pass through each other without colliding.
Image



Affected Browsers
  • NW.js: YES
  • Chrome: YES
  • FireFox: YES
  • Opera: YES
  • Iron: YES
  • Internet Explorer: YES



Operating System and Service Pack
Win7 x64 - Pro
SP1



Construct 2 Version ID
Release 247 (64- bit) checked
Built at 13:33:48 on Sep 21 2017
Release Notes
B
27
S
18
G
8
Posts: 328
Reputation: 6,158

Return to Bugs

Who is online

Users browsing this forum: No registered users and 0 guests