Locomotion validation
This module extends the locomotion system available in VRShared, to validate some locomotion attempts before applying them (locked places, places with limited capacities, restricted area, personal safe zone, ...).
Locomotion validation system
To determine if the user is not trying to go to a forbidden zone, every locomotion system first asks the HardwareLocomotionValidation component, placed on the HardwareRig, if they can move to this position, with the CanMoveHeadset() method. To answer, the HardwareLocomotionValidation first checks if the move is valid with all its ILocomotionValidator childs, and all the ILocomotionValidator childs of the NetworkLocomotionValidation component, placed next on the NetworkedRig instance representing the local user on the network.
This allows to have 2 kind of restrictions:
- restrictions to offline data (hardware info, static scene, ...)
- restrictions associated to the networked state of the user
Other restrictions
Additionally, the locomotion is limited by other factor, depending on the locomotion system used:
RigLocomotion: an user can only teleport on an collider with a layer in the RigLocomotion's locomotion layer mask (like theTeleportTargetlayer)LocomotionValidatedDesktopControllerdesktop locomotion : for desktop builds, as moves initiated by the keyboard would allow to ignore theRigLocomotionteleport restrictions, this controller checks that the head position after a move would be correct, by checking:- if it would not be inside a collider after the move
- if a correct walkable navigation mesh point will be under it after moving
Demo
A demo scene can be found in Assets\Photon\FusionAddons\LocomotionValidation\Demo\Scenes\LocomotionValidation.unity.
The scene contains several areas connected by bridges.
These objects have a different configuration regarding the layer and the navmesh parameters :
- Green objects : set to
Walkablein Navigation & layer is set toLocomotion(same as the rigRigLocomotionLocomotionLayerMaskparameter), so players can move & teleport on them, - Red objects : set to
Not Walkablein Navigation & layer is set toForbiddenLocomotion, so players can NOT move or teleport on them, - Orange objects : set to
Not Walkablein Navigation & layer is set toLocomotion(same as the rigRigLocomotionLocomotionLayerMaskparameter), so players cannot walk up to them but they can teleport on it. - Grey cylinders : they are referenced in the
ForbiddenZonescomponents (HardwareRig&DesktopRig). TheForbiddenZonescript demonstrates how to implement theILocomotionValidatorinterface. In this example, theCanMoveHeadset()function ofForbiddenZonereturn false when the player head is in the zone area in order to trigger the fader (thanks to theInvalidMoveCameraFader&HardwareLocomotionValidationscripts).
Please note that if a player teleports to on orange object, he can then walk on it to avoid being blocked in this area. Then, the locomotion validation will be activated again when the user returns to a green object. If you want to avoid this behavior, make sure thatNot Walkableobjects are in theForbiddenLocomotionlayer.
Download
This addon latest version is included into the addon project
Supported topologies
- shared mode
Changelog
- Version 1.0.2: Improve demo scene with ForbiddenZones
- Version 1.0.1: Add demo scene + add namespace
- Version 1.0.0: First release