Accessing transform from jobs

Anyway to access the Transform from the jobs system?. it can be accessed from the foreach no problems:

transformQuery = GetEntityQuery( ComponentType.ReadOnly<Transform>());
Entities.With(transformQuery).ForEach(
           (Entity entity, Transform transform) =>
           {
             //  Debug.Log(transform.position);
           });

Alternatively is there any other way to move a gameobject entity(that isnt using the convert to entity script) within the jobs system?

1 Like

There’s an IComponentData tag type called CopyTransformToGameObject that will do this for you. Simply add it during conversion and it works automatically.

Or if you need to do this manually, look up the TransformAccess structure.

1 Like

thanks for the reply, is that without using the ‘convert to entity’ script and just the ‘gameobject entity’ script?

Yes, look at the IConvertGameObjectToEntity interface.

Here’s a sample:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/Samples/Assets/HelloCube/6.%20SpawnFromEntity/SpawnerAuthoring_FromEntity.cs

yes i have tried this, the object that has the IConvertGameObjectToEntity script needs to have the convert to entity script attached. the reason i am avoiding this script is there is a major movement stutter bug.
if i just attach gameobjecentity on a basic cube i can see ‘box collider, enttiy, mesh filter, mesh renderer, transform’ in the entity debugger . is that a way to access the transform manually using TransformAccess?

You can look at how CopyTransformToGameObjectSystem works, there are some older examples of TransformAccess and TransformAccessArray here that may prove useful. You’ll need to use IJobParallelForTransform to use it correctly.

1 Like