The holoride Player
For easy integration, the Elastic SDK provides a holoride Player Prefab for Unity that is controlled by the car’s sensors and moved through the elastic experience. A camera rig must be parented under the holoride Player's GlobalRotation to add the current head rotation to the mix. Decorating objects or user interfaces can be attached to either of them.
In addition, the sensor data can be accessed at any time. It can serve as a constantly updating parameter to emphasize the visual feedback to velocity, acceleration and rotation provided by affecting particles, loose objects, or moving characters. It is also possible to exaggerate the whole vehicle’s motion to imitate a jet that leans into the bend, or a sailboat that is dragged in the opposite direction—an effect that can be achieved using our Floating Platform component.
Tip
You can create a holoride Player game object in Unity's scene hierarchy from the right-click context menu Create > holoride > Player.
The root game object HoloridePlayer performs the vehicle 3D translation and heading about the y-axis (i.e. the vertical axis with respect to the ground).
Note
In this scene, the debug bool for Show Debug Visualization is set to true, allowing us to see the rotations.
The player prefab is made of 3 parts:
- Global Rotation
Content is aligned to the global coordinate system. This means that, when the vehicle turns the content does not turn with it. Place any persistent background objects here, such as mountains or hills.
Note
Note: For testing in a moving vehicle, place the main camera or camera rig here.
- Local Rotation Content is aligned with the local coordinate system of the vehicle but it only consists of translation and yaw rotation of the vehicle. Neither roll nor pitch rotation is applied. Content moves as if attached to the vehicle.
Note
For testing at your desk, place the main camera or camera rig here.
Floating Platform
The FloatingPlatform uses translation and all rotation axes of the vehicle. Placing a cockpit model here and adjusting the associated curves in the editor will give the feeling of banking, when the real-world vehicle turns. With these curves, we can also emphasize acceleration or braking forces of the vehicle.
World Shift Manager
The World Shift Manager is a component that shifts all objects back to the origin if the player moves further away than the threshold set in the component. This is done to avoid inaccuracies and errors that occur when driving in the real world too far away from the generation pivot.
Game objects parented under either of the above Player Transforms, as well as the ones generated by the Elastic Scene Generator, are automatically registered for the shift process. Game objects that are not parented under one of the above mentioned Player Transforms or are spawned by the Elastic Scene Generator can be registered by using the AddShiftParent method or via the component inspector.
Localization Events
Localization Events are located on a component with the same name in the Holoride Player prefab. These events are meant to be hooks where your program flow can execute different behavior based on the different states of the real-world localization data.
Setting | Description |
---|---|
DistanceToStreetUntilOffRoad | The distance in meters from the street until the player is considered to be too far away from the road and the OnOffRoadMode event is triggered. |
FireModeEventOnStart | When enabled this component will fire the localization mode event for the current state when Unity's Start method is called on this component. |
Event | Description |
---|---|
OnLocalizationInitialized | The event which is invoked when the localization becomes available and the pivot is set. |
OnLocalizationNormalMode | The event which is invoked when the localization is available and we are on the street (up to the road distance threshold). |
OnOffRoadMode | This event which is invoked when the localization is available but we are not on the road and the distance to the road is larger than the threshold configured in DistanceToStreetUntilOffRoad. |
OnLocalizationUnavailableMode | This event which is invoked when the localization is unavailable and thus the player won't move even though the vehicle in the real world might. |
OnErrorOccured | This event which is invoked when any localization error occurs. |
This component handles different localization quality events and reduces them to three distinct states:
- Normal:
This state represents good localization where everything works as expected. - Off-road:
This state is active when the localization is available but due to inaccuracies in localization or outdated Map data, the Player might not be on the road which the content should handle accordingly. The distance to the road until the player is considered to be "off-road" is adjustable and should reflect the requirements of the individual content. - Unavailable:
This state means that no localization information is available.
Provisions should be made for the content of an experience to respond to different localization states:
Since the Unavailable state does not show any movement at all, even though the vehicle may in fact be moving, it is suggested not to show any indication of false movement that occurs when the Player's localization is not present but the VR headset's IMU interprets a turning car as a head rotation.
In many scenarios, this means that it is not even recommended to show the player a world . The experience should start in this mode until localization is available and Map data is ready.
Caution
Any experience must be designed to reflect this state at any point in time to comfort the user in those situations where valid data is not available to present an elastic environment. One suggestion is to fade out the world when this mode is activated and fade it in once another state becomes active.
The other interesting state is the Off-road state where there appears to be normal localization but due to limited GPS reception (e.g. in a tunnel) the Player might be off the road. In this case the experience should make sure that the player is not colliding with any objects. How this is handled depends very much on the experience that is built and could range from unloading objects that are too close to loading a different scene. The Distance To Street Until Off Road setting for this mode makes it possible to tighten or loosen the constraints for this mode, depending on the individual content.