How to Spawn a Player in ECS XR

This will take you about 20 minutes in prep time if you don't have Unity set-up, and 30 minutes in coding and debug time.

Click Here for DOTS Tutorial

Stop struggling with the limited documentation. Follow this step-by-step tutorial: "How to Spawn a Player in ECS XR."

Full workflows and code to programmatically spawn a Player

Click Here for DOTS Tutorial

This gitbook takes you through step-by-step full workflows and code to programmatically spawn a Player. Once you've coded along and fully finished the "How To Spawn a Player" tutorial, you will be able to programmatically spawn a Player.

Click Here for DOTS Tutorial

High-Level steps to Spawn a Player:

Number 01

Create a Player prefab and give it an authoring component

Number 02

Create an empty GameObject that will hold all references to Player prefabs

Number 03

Create a spawning system which spawns Player entities from user input (such as a keystroke)

FAQ

What is a World in ECS XR?

A World organizes entities into isolated groups. A world owns both an EntityManager and a set of Systems. Entities created in one world only have meaning in that world, but can be transfered to other worlds (with EntityManager.MoveEntitiesFrom). Systems can only access entities in the same world. You can create as many worlds as you like.

What is an EntityManager in ECS XR?

The EntityManager provides an API to create, read, update, and destroy entities. A World has one EntityManager, which manages all the entities for that World. Many EntityManager operations result in structural changes that change the layout of entities in memory. Before it can perform such operations, the EntityManager must wait for all running Jobs to complete, an event called a sync point. A sync point both blocks the main thread and prevents the application from taking advantage of all available cores as the running Jobs wind down.

What are system types in ECS XR?

SystemBase - this is the type of system used most of the time for runtime game play. The systems of this type will do things like provide movement to asteroids or Spawn/Destroy. ComponentSystemGroup - this is groupings of systems. GameObjectConversionSystem - We have interacted with these systems when working with our GameSettingsComponent and our SetGameSettingsSystem. These are used for hybrid development. EntityCommandBufferSystem -EntityCommandBufferSystems are used as "sync" points for structural changes to entities.

Haven’t begun learning Unity DOTS yet, and need to start at the very beginning?

If you haven't yet dipped your toes into learning Unity's new multithreaded Data-Oriented Technology Stack (DOTS), now is the time. You can start at the very beginning with Moetsi’s tutorial, which culminates in your very own deployable sample project. You’ll be guided by full workflows, code-alongs, videos, and GIFs along the way.

Get Started