Getting Started

Introduction

Installation

Project Configuration

Testing in Your Sandbox

Samples & Examples

Core Concepts & Glossary

Package Types

Spaces & Space Templates

Custom Avatars

Custom Avatar Animations

Avatar Attachments

Custom Prefab Objects

Embedded Packages

Drivable Vehicles

Scene Setup

Testing In Unity vs Sandbox

Controlling the Camera

Custom Collision, Layers, and Tags

Audio Mixers and Groups

Key Differences from Standard Unity3D development

Economy

Quests and Rewards

Economy Overview

Monetization

Entrance Point

Interactable

Drivable Vehicles

https://youtu.be/Mzi9ArqvCAM

<aside> <img src="/icons/star_green.svg" alt="/icons/star_green.svg" width="40px" /> If you are new to the Creator Toolkit, make sure to check out following page to get your Unity editor setup!

Getting Started (OLD)

</aside>

<aside> <img src="/icons/book_gray.svg" alt="/icons/book_gray.svg" width="40px" /> This guide will show you how to set up a drivable vehicle that can be used in Spatial. This is to be used in conjunction with the Custom Prefab Object package type, which you can reference in the package configuration.

</aside>

Importing a Vehicle Model & Requirements

Screenshot 2023-04-11 at 1.09.54 PM.png

Setting Up Your Vehicle (Grounded, 4-wheeled)

  1. Change the Layer of your vehicle to Vehicles

    Screenshot 2023-04-10 at 4.45.50 PM.png

  2. Add Rigidbody component to the top level of your vehicle’s hierarchy

    1. Make sure to add the Mass of your vehicle (in KG), as well as the Drag and Angular Drag values.
    2. Leave Interpolate and Collision Detection as default
  3. Place an empty GameObject for the driver seat position, and move it to the location where the driver will be seated (NOTE: do not add it as a Seat Hotspot)

    1. Make sure it’s a child object of the vehicle

    Screenshot 2023-04-11 at 2.45.54 PM.png

  4. Add a Mesh or Box Collider to the vehicle’s body

  5. Add a Center of Mass

    1. Create an empty Game Object, rename it “Center of Mass”
    2. Move the empty object to the approximate position of the Center of Mass of the vehicle
  6. Add Wheel Colliders for each wheel (make sure you have a rigidbody on your vehicle first

    1. Create a new empty Game Object called “Wheel Colliders” to place all the wheel colliders into
    2. With Wheel Colliders, create a collider for each wheel
      1. Create an empty Game Object
      2. Add the Wheel Collider component to the Game Object
      3. Give the colliders a consistent naming convention - for example “FR - Collider” for the Front Right wheel.
      4. Move the collider so it’s perfectly centered on the wheel
      5. Adjust the radius of the collider so it’s just visible around the wheel

    <aside> <img src="/icons/car_yellow.svg" alt="/icons/car_yellow.svg" width="40px" /> Make sure to set the proper values of your Wheel Colliders’ properties specific to your vehicle.

    Learn more about Unity’s Wheel Collider Component here.

    </aside>

    <aside> <img src="/icons/warning_gray.svg" alt="/icons/warning_gray.svg" width="40px" /> Ensure the wheel colliders and wheel meshes are facing the same orientation (Z+ forward orientation).

    </aside>

    Wheel mesh (blue outline), with the Wheel Collider (green line) visible around the tire. Both have the Z+ (blue arrow) pointing towards the front of the vehicle.

    Wheel mesh (blue outline), with the Wheel Collider (green line) visible around the tire. Both have the Z+ (blue arrow) pointing towards the front of the vehicle.

  7. Add 2 Interactable components (no modifications or events for these Interactables needed)

  8. Add a Variables component

    1. To the top level vehicle object, add a Variables component

    2. Open the Vehicle sample provided in the Starter Template, and copy it’s Variables component as shown below

      Screenshot 2023-04-10 at 6.04.51 PM.png

    3. Paste the Component values back in the Variables component of your vehicle

      Screenshot 2023-04-10 at 6.08.22 PM.png

  9. Assign your vehicle’s assets to the relevant Variables

  10. Set values for other Variables

  11. Add a Script Machine component to your vehicle to the top level of your vehicle

  12. Add a Synced Object Component

    1. Check Sync Transform
    2. Under Synced Variables, enable the following variables to be Synced
      1. isControlled
      2. drive
      3. steer
      4. brake
      5. isHonking

    Screenshot 2023-04-11 at 1.07.08 PM.png

  13. If publishing as an individual object that can be accessed from your Content menu, add the Prefab Object Component

Vehicle Sample - Golf Cart

My Sandbox on 4-11-23 at 5.11 PM.png

Introducing our sleek and stylish golf cart, perfect for developers who want to go for a test drive around Spatial in style. This little beauty will have you feeling like you're cruising down the fairway, even if you're just making laps around the parking lot. So hop on in, hit the gas pedal (or the brake if you're feeling cautious), and enjoy the ride. Just don't forget to yell "fore!" before taking any sharp turns!

<aside> 👉 Click below to download the sample from the Samples page, bring it into your project and review how to properly set up your own drivable vehicle!

Samples & Examples

</aside>

← Previous

Custom Prefab Objects

Next →

Entrance Point