I have tried to implement a respawn mechanism that is automatised. In the sense that, if we give the RespawningManager to the parent element, it automatically respawns all the child when a checkpoint has been hit or if we hit the outOfBounds platform. This is plug and play, it should work in every scene without manually changing the prefab.
Bullet points overview:
Add a script uniquely dedicated to respawn called RespawningManager.cs
Add a script uniquely dedicated to collisions of reality player called RealityPlayerCollisions.cs
Remove parts related to collisions in the script RealityMovement.cs, which is already quite long
Update OutOfBounds prefab: add tag and remove script that manages the collisions
Update Checkpoint prefab: add tag and remove script that manages the collisions
Update AllPlayer prefab: add respawning manager and collision manager scripts as components
Remarks
This is quite a change with respect to the first implementation of @bottolo, so maybe before merging the PR it would be great to have a review from his side
In general, this is also a step toward centralizing the collisions in the RealityPlayerCollisionsscript. If we need more discussion on this, we can keep this PR as a base for the discussion. My opinion is that in this way the code is quite easy to read and to manage!
Interesting fact: I have changed all the prefabs, canceled scripts, and did not any change at all Scene_1... but Scene_1 is still working! :) Anyway I kept Scene_3_new_respawn_structure.unity as I am afraid of conflicts if other PRs get merged, feel free to remove it!
Changes
I have tried to implement a respawn mechanism that is automatised. In the sense that, if we give the RespawningManager to the parent element, it automatically respawns all the child when a checkpoint has been hit or if we hit the outOfBounds platform. This is plug and play, it should work in every scene without manually changing the prefab.
Bullet points overview:
RespawningManager.cs
RealityPlayerCollisions.cs
RealityMovement.cs
, which is already quite longOutOfBounds
prefab: add tag and remove script that manages the collisionsCheckpoint
prefab: add tag and remove script that manages the collisionsAllPlayer
prefab: add respawning manager and collision manager scripts as componentsRemarks
RealityPlayerCollisions
script. If we need more discussion on this, we can keep this PR as a base for the discussion. My opinion is that in this way the code is quite easy to read and to manage!Interesting fact: I have changed all the prefabs, canceled scripts, and did not any change at all Scene_1... but Scene_1 is still working! :) Anyway I kept Scene_3_new_respawn_structure.unity as I am afraid of conflicts if other PRs get merged, feel free to remove it!