Social Distancing

Topology
SHARED AUTHORITY

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.

Fusion XR-prototyping-modules Social Distancing ForbiddenArea
Fusion XR-prototyping-modules Social Distancing ForbiddenArea

The SocialDistancing class must been added to the network player prefab.

Fusion XR-prototyping-modules Social Distancing
Fusion XR-prototyping-modules Social Distancing

It implements the ILocomotionValidator interface. So, the CanMoveHeadset method checks if the player's head is above the ForbiddenAreadefined above by performing a raycast towards the ground. The raycast only hits the layers of its forbiddenLocomotionLayerMask, which is empty by default (the feature is then off): set it to the layer of the ForbiddenArea objects (ForbiddenLocomotion in the demo, applied with a LayerSetter). 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 a child object of the network player prefab, with a SpriteRenderer, and reference it in the socialDistancingVisualFeeback field of SocialDistancing (in the demo, the ForbiddenAreaVisualFeedback object). Then SocialDistancing can call the DisplayForbiddenArea() method which displays a sprite for a certain period of time. SocialDistancing moves this object under the user head at each frame: never put the component on the rig root.

Fusion XR-prototyping-modules Social Distancing SocialDistancingVisualFeeback
Fusion XR-prototyping-modules Social Distancing SocialDistancingVisualFeeback

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 Samples/SocialDistancing/Scenes folder.

Fusion XR Addon Social Distancing
Fusion XR Addon Social Distancing

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.

Dependencies

  • XRShared addon
  • Locomotion Validation addon: the locomotion systems check SocialDistancing through its HardwareLocomotionValidation (on the hardware rig) and NetworkLocomotionValidation (on the network rig) components

Download

This addon latest version is included into the XR Addons project

Supported topologies

  • shared mode

Changelog

  • Version 2.1.0: Update to support new XRShared architecture
  • 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

Last updated on

Back to top