ExistentVehicle
Last updated
Last updated
Overview
An ExistentVehicle is the core system Existent provides for locomotion across the virtual world. Whenever you create an experience where Players can traverse an area larger than a single Space, we recommend using a Vehicle to “drive” them between Spaces. From a design perspective, the Vehicle metaphor works well when combined with a mesh (e.g. a car or a lift) and RealityBridge interactions (e.g. fan wind or floor vibrations) to give Players a believable context for the locomotion.
In technical terms, however, a Vehicle is simply a special type of Space with built-in functionality for moving smoothly from one Space to another, ensuring that all its children are perfectly aligned with the source and destination Space at either end of the drive. A Vehicle exists in one of three states: “stationary at source”, “driving”, and “stationary at destination”, and exposes a blueprint-accessible API for transitioning between these states while the game is running.
By default, a Vehicle moves in a straight-line linearly interpolated path between the source and destination Space over a developer-specified number of seconds, but also provides an optional SplineComponent which can be modified by hand to create a custom path to the destination.
In the Unreal editor (or in-game with backstage mode enabled), a Vehicle is visualised as a white Space with a gradient-coloured line going between the source and destination Spaces, with a car icon at either end. To prevent cluttering the UI, the Vehicle’s grid mesh (see the Space section) is only visible in-game while in the “driving” state.
You can drag and drop an instance of the ExistentVehicle Actor into your level or create your own blueprint class that extends the ExistentVehicle class. From there, assign values to the Source Space and Destination Space properties by linking them to Spaces that already exist in your level. Once this has been done, the Vehicle should automatically snap to align to the source Space.
To initiate driving while the game is running, you can invoke the Drive() function, which takes in a list of Players and props to take along for the ride, and automatically inserts them into the destination Space once the drive has completed.
By default, a Vehicle will drive in a straight line at constant velocity from the source to the destination Space, over the time provided in the Driving Time Secs property (10 by default). If you would like to provide a custom path between the source and destination, however, enable the Use Spline property, and modify the Path Spline component to draw an Unreal spline for the Vehicle to follow.
If your Vehicle Actor contains a mesh, you can enable the Align to Mesh property, and select the relevant mesh in the Vehicle mesh property. This will align the Vehicle icon and connecting line to be centred on your mesh, to better visualise the start and end point of the Vehicle’s path.
Automatic Player and prop transfer: The Vehicle automatically handles transferring all desired Players (as well as any props they’re holding) smoothly from the source to the destination Space, placing them in the destination Space when the Vehicle arrives.
Blueprint-accessible API:
Drive() initiates driving to the destination Space, and takes in a list of Players and props to take along for the ride.
ResetToSource() resets the Vehicle back to the “stationary at source” state.
Reverse() swaps the source and destination Spaces. NB: Will not reverse the path of a custom spline.
The OnArrivedAtDesination event is fired when the Vehicle arrives at the destination Space.
Smooth spline-based movement: If you’re building a custom path for the Vehicle to take when driving, Existent will automatically handle aligning the Vehicle smoothly with the source and destination Spaces at either end of the drive, even if the start and end points of your spline do not line up perfectly. We recommend enabling the Visualize Roll and Scale option when selecting the spline component in the Unreal editor to ensure there are no sudden jumps or rotations elsewhere in your path.
Server-authoritative: For multiplayer experiences, all Vehicle functions only need to be invoked once on the server machine, and the Vehicle’s state and location (including which Players and props are attached) will automatically replicate to all other connected clients.