Use methods of Transform without linked gameObject

So i’m looking for the functions similar to those on the Transform class on an object that I can easily set and get in my own scripts. I think the API of the Transform class is really clear and easy to understand as opposed to the Mat4x4 which seems more linked to the mathematical terms.

I would rather not wrap up the Mat4x4 class that acts similar to the Transform class, like so:

namespace Math {

    public struct MatTransform {

        public Matrix4x4 mat;

        Vector2 right { get { return this.mat * Vector3.right; } }
        Vector2 left { get { return this.mat * Vector3.left; } }
        Vector2 up { get { return this.mat * Vector3.up; } }
        Vector2 down { get { return this.mat * Vector3.down; } }

        Vector2 TransformPoint(Vector2 vec)
        {
            return (Vector2)mat.MultiplyPoint3x4((Vector3)vec);
        }
        Vector2 TransformDirection(Vector2 vec)
        {
            return (Vector2)mat.MultiplyVector((Vector3)vec);
        }
    }
}

And the rest of its methods.

In short, I don’t want to instantiate a gameObject and access its transform. But I want to store a local transformation space within my script and access/change it with the functions as are on the Transform class.

Sad to day that you only have two options, both of which you already know.

  1. Make an empty gameObject which is the local transform.

  2. Create a helper class like the above.

Make sure you’re not prematurely optimizing though. If you want to have a sub object with a local transform that uses the transform API, maybe use use a Transform! Unless you have profiled or have some calculations that suggest having a real game object will be a problem, then why optimize something that may never be a problem?