How to Destroy 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 Destroy a Player in ECS XR."

Full workflows and code to self-destruct as a Player

Click Here for DOTS Tutorial

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

Click Here for DOTS Tutorial

High-Level steps to Destroy a Player:

Number 01

Update current spawn system to add a Destroy Tag when key is pressed

Number 02

create destroy system to destroy Player entity

Number 03

press play to test out hitting key for Player to self-destruct

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.

How do you add a camera to a Player in ECS XR?

Right click in the Player prefab Hierarchy and create a Camera GameObject Change the position to (0, 2, -5) And make sure your Player prefab has a Transform of (0, 0, 0). Woo, all set! Right? Not quite, why isn't the camera updated to the Player prefab's Camera GameObject? The Camera is a GameObject but is being instantiated through ECS... a little wonky To fix this we need to add HYBRID_ENTITIES_CAMERA_CONVERSION to the Player Settings

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