How can I access an entity in subscene from MonoBehaviour?

Hello everyone, I was trying to make Cinemachine work (or just make a custom script that follows the entity) however I am having hard times figuring out how can I access the entity from the MonoBehaviour. I was following this tutorial from Turbo Makes Games however it is outdated and not working anymore.

Basically I am trying to copy the position and rotation of an entity to a GameObject. How can I achieve this?

Just use same Unity version as on the tutorials. Always.

You should be asking this question in the scripting sub forum. Ti’s isn’t support forum.[/]

Hi, couple of options:

  1. Add required MonoBehaviour to the Entity via EntityManager.AddComponentObject and use managed system (SystemBase) to iterate upon those (.WithoutBurst().Run()). Set position & rotation as needed.
  2. Use sync job to write to the Transform via TransformAccessArray (e.g. see job and how to add Transform);
  3. Use bakers / conversion, convert Transform to Entities Transforms and use components from the Transforms package to sync basically in the same way (via TAA, handled by Transforms systems);
2 Likes

It’s not “General” though. :stuck_out_tongue:

1 Like

Oh lol, in DOTS… I thought it was in general. Sorry then.

2 Likes

Thanks, I’ll try!