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

Custom Collision, Layers, and Tags

What Is Effective Layer?


Untitled

Internally, Spatial requires the objects in your scene’s to be on certain layers. Specifically, only layers 6 - 14 and 31 are allowed. The Effective Layer section will show you what layer your game-object will be set to when loaded in Spatial and gives you a drop-down of all the supported layers.

You will notice that everything besides layer 6-14 will be set to layer 31 or "Environment".

<aside> <img src="/icons/warning_red.svg" alt="/icons/warning_red.svg" width="40px" /> The system that changes the scenes layers does not exist when you instantiate with VS or enter play mode in-editor. Because of this we recommend you always choose a specific layer for your objects instead of leaving them on default

</aside>

Customizing Collision


In the Creator Toolkit you can customize the collision matrix for a select number of layers.

To do this navigate to your Project Settings then open the Physics tab.

If you scroll down you will see the collision matrix for your project. Here you can enable or disable any of the collision settings for the layer pairs shown in green in the image below.

Untitled

Utilizing Custom Layers


The basic Unity collision system will work as you expect when you change the matrix. If you are new to Unity make sure to check out their documentation on how the layer system works.

Additionally, inside Visual Scripting you can now raycast and target specific layers.

You can do this with a Layer Mask to look for objects that are only on a particular set of layers.

Untitled

DO NOT use Name to Layer functions


The names of your layers are not preserved when loaded in Spatial which means Name To Layer nodes will most likely return -1.

The following nodes will NOT work as expected because Spatial does not internally have a layer named CustomLayer1.

Untitled

Tags are not supported


Untitled

Although tags appear as just strings, they function roughly the same as layers with an ID. What this means is that when Spatial loads your bundle all the tags on your objects will be converted to the corresponding tag in the internal Spatial project. Unfortunately there is not really a path to re-map tags the way we do with layers, so we recommend you ignore them completely.

“Tagging” objects in other ways


Just because you can’t use the tags field doesn't mean you can’t “tag” an object with information. Here are the two main ways I recommend going about this:

1. Just Use Layers

Untitled

The simplest method is just to use the limited custom layers as object IDs. For an action game you could keep all projectiles on one layer, and all enemies on another. Then you can modify your collision matrix so that projectiles can ONLY collide with enemies. Implicitly meaning anytime a projectile fires a collision event you know it has hit an enemy.

Untitled

2. Tag with Visual Scripting Variables

With visual scripting you can add a Variables component to any object and assign variables to it.

Untitled

You can then attempt to access these variables from any gameObject by passing a gameObject into the object field on the Get Variable node like shown below.

Untitled

Be careful though! If you aren't confident that the gameObject in question will have the variable it is good to check for it using the Has Variable node like the example below in order to avoid an exception.

Untitled

← Previous

Add link here

Next →

Add link here