Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by BigRoy · Oct 05, 2014 at 09:29 PM · transformmatrixtransformation

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.

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

1 Reply

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

Answer by MakeCodeNow · Oct 06, 2014 at 06:51 AM

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?

Comment
Add comment · Show 3 · 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 BigRoy · Oct 06, 2014 at 10:58 AM 0
Share

I would be using it for an extensive set of objects. It wouldn't directly be an optimization but more an 'ease-of-use' in the long run. ;) Thanks for the tips though, I'll definitely have to double check what is the best road to take down the line.

avatar image MakeCodeNow · Oct 08, 2014 at 03:25 AM 0
Share

No prob! Please mark answer as accepted.

avatar image BigRoy · Oct 08, 2014 at 04:50 PM 0
Share

Will do. Even though I still hope it would've been easier. ;)

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

28 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Fixing normals on projected texture. 0 Answers

Matrix to transform bone orientation to world orientation 0 Answers

Maya rotation transformation to Unity 0 Answers

Is there such a thing as Unity Algebra? 0 Answers

Transform to matrix 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