How to Move a Player in DOTS

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 Move a Player in DOTS."

Full workflows and code to programmatically move a Player from user input

Click Here for DOTS Tutorial

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

Click Here for DOTS Tutorial

High-Level steps to Move a Player:

Number 01

create the player prefab and give it an authoring component

Number 02

create the InputMovementSystem to take in "WASD" and mouse input

Number 03

adjust the rotation and velocity of the Player entity with user inputs

FAQ

What is a World in DOTS?

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 DOTS?

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 DOTS?

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