Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by DSimkin · May 20, 2013 at 10:06 PM · gameobjectinstantiatetransformconstructor

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Excrubulent · Jul 12, 2013 at 01:47 PM 1
Share

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.

avatar image
2

Answer by anamta93 · Oct 12, 2018 at 05:26 AM

This could help :)

     GameObject emptyGO = new GameObject();
     Transform newTransform = empt.transform;
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Oct 12, 2018 at 09:13 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotating a Vector3 in Instantiation 1 Answer

Instantiating from an object that's in an array 1 Answer

The Weirdest Bug Ever: GameObject Transform Appears in Editor to Be in One Spot but Instantiates and Registers in Another 2 Answers

Show points text on collision 0 Answers

Instantiated Object Not Animating 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges