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.
SocialDistancing class must been added to the network player prefab.
It implements the
CanMoveHeadset method checks if the player's head is above the
ForbiddenAreadefined 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.
A demo scene can be found in
The player network rig contains a
ForbiddenArea : it is a simple capsule. This game object is set to the
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.
This addon latest version is included into the addon project
- shared mode
- Version 1.0.2: Namespace modification
- Version 1.0.1: Add demo scene + add namespace
- Version 1.0.0: First release