How can I obtain vectors like transform.up when using a TransformAccess?

I’m using a TransformAccess inside an IJobParallelForTransform job, and I’d like to be able to compute a set of vectors in this job and write them to a NativeArray as output.

Ideally, I would just return transformAccess.up, transformAccess.right, etc. But these aren’t available in the TransformAccess API, so I think I need to compute them myself. Is there a Vector3 transformation I can apply, or do I need to do the math manually? If I have to do it manually, I think I’m overthinking the math itself, and would appreciate some pointers.
Thanks!

1 Like

The math is pretty simple, just multiply the world vector you want by the object’s world rotation.

I have not used that IJobs transform accessor you refer to, but if you have the Quaternion that is the object’s world rotation (ie., normally called transform.rotation outside of Jobs/ECS), then the various helpers are:

transform.up is transform.rotation * Vector3.up
transform.right is transform.rotation * Vector3.right
transform.forward is transform.rotation * Vector3.forward

5 Likes

Thank you!

1 Like