Social Distancing
Social Distancing
To avoid two players being too close, we provide a "Social Distancing" module.
To do so, the network player prefab must contains a ForbiddenArea
game object with a collider (capsule collider for example). This represent the forbidden area to all other remote players.
The SocialDistancing
class must been added to the network player prefab.
It implements the ILocomotionValidator
interface.
So, the CanMoveHeadset
method checks if the player's head is above the ForbiddenArea
defined above by performing a raycast towards the ground.
To avoid auto collision detection, the ForbiddenArea
is deleted during the Spawned()
for the local network rig.
When a collision is detected, movement is prohibited and a visual feedback can be displayed to indicate the prohibited area.
To add a visual feedback, add the SocialDistancingVisualFeeback
class to the network player prefab. Then SocialDistancing
can call the DisplayForbiddenArea()` method which displays a sprite for a certain period of time.
Please note that the mechanism does not prevent two players from getting closer if they move towards each other simultaneously.
Demo
A demo scene can be found in Assets\Photon\FusionAddons\SocialDistancing\Demo\Scenes\
folder.
The player network rig contains a ForbiddenArea
: it is a simple capsule. This game object is set to the ForbiddenLocomotion
layer.
Also, a circle sprite renderer is located on the network rig. Thanks to the SocialDistancingVisualFeeback
, the circle is displayed when a distant player attempts to move or teleport to the player so that they can understand why the move is not successful.
Download
This addon latest version is included into the Industries addon project
Supported topologies
- shared mode
Changelog
- Version 2.0.0: Fusion 2.0 support
- Version 1.0.2: Namespace modification
- Version 1.0.1: Add demo scene + add namespace
- Version 1.0.0: First release