- Home /
Create a Transform without a GameObject
The Transform class has lots of functionality that I'd like to be able to use, but I don't want to have to create a GameObject just to transform a list of points.
Is there a way to directly instantiate Transform, or is every instance of Transform a component of a GameObject?
Is there another class that has a TransformPoint method or something similar?
Answer by Julien-Lynge · May 20, 2013 at 10:10 PM
No, Transform is a type of MonoBehaviour (e.g. a component), and cannot be directly constructed from code. There aren't any other classes provided by Unity that contain Transform's functionality but in a way that isn't tied to a GameObject. You could try places like the wiki: http://wiki.unity3d.com/index.php/Scripts/General
Depending on what you want to do, a transform may be easily replicated with two Vector3s (for position and scale) and a quaternion (for rotation). You can then use all the methods of these classes to accomplish translations, rotations, looking at a target, etc.
This is a good answer, but one of the things you'll be missing from the Transform class is the ability to parent to another Transform. Transforms can only parent to other Transforms, and vice-versa. As far as I know, the only way to access Unity's build-in parenting is to use a Transform, so if that's what you're after, creating empty GameObjects may be the only way to do it.
Answer by anamta93 · Oct 12, 2018 at 05:26 AM
This could help :)
GameObject emptyGO = new GameObject();
Transform newTransform = empt.transform;
Wait you answer the question "Create a Transform without a GameObject" with the answer "just create a gameobject"? The correct answer is "no", just as julien said. However there are other types which can accomplish the same task that the Transform component does. Specifically $$anonymous$$atrix4x4. A Transform essentially is just a $$anonymous$$atrix4x4 though it stores the things needed to create the matrix seperately so they can be changed easily
Your answer
Follow this Question
Related Questions
Rotating a Vector3 in Instantiation 1 Answer
Instantiating from an object that's in an array 1 Answer
Show points text on collision 0 Answers
Instantiated Object Not Animating 1 Answer