Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 kanejunk · Dec 22, 2019 at 11:35 AM · transformvector3direction

InverseTransformDirection and TransformDirection

I am now making a ladder climbing feature and I have a problem about direction. So I try to test InverseTransformDirection function and TransformDirection function with an empty gameObject that has (0,270,0) Rotation(shown in inspector). Here is the code.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class char_control : MonoBehaviour
 {
     public Transform testobj;
     public Vector3 localdir;
     public Vector3 worlddir;
     public Vector3 localdirResult;
     public Vector3 worlddirResult;
  void Update()
     {
         worlddirResult = testobj.TransformDirection(localdir);
         localdirResult = testobj.InverseTransformDirection(worlddir);
 }
 }

And this is the value that the functions return alt text why the function return weird z value in WorldirResult when I input z =1 in Localdir,I think z value should be 0. this is the inspector of Testobjalt text

untitled.png (11.7 kB)
untitled2.png (8.4 kB)
Comment
Add comment · Show 1
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 RobAnthem · Dec 22, 2019 at 04:09 PM 0
Share

Rotation and direction are very different. The direction is just represented by 0-1 on each axis. So 0,1,0 would be Vector3.up. Whereas for the model to face upwards, you would need a rotation of -90,0,0. Another example is that a left direction is -1,0,0 but for an entity to face left, it would need a rotation of 0,-90,0. So trying to get direction the way you are doesn't really make sense. Besides, if done properly your directions should be Player.transform.up, and Ladder.transform.up, or Player.transform.forward, etc. Like if you wanted the player to rotate towards the opposite facing direction of the ladder, you'd want the player's forward direction to be -Ladder.transform.forward.

1 Reply

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

Answer by mateusthiago · Jul 22, 2020 at 02:04 PM

That weird number actually means something that could be considered 0, as it is a product of floating point imprecision. That ending with e-n means that number is actually multiplied by 10 to the -nth power, or 0.(n zeroes)1192093 in the case of your number. See these for a better understanding: https://sciencing.com/end-number-mean-7430704.html https://floating-point-gui.de/

Comment
Add comment · 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

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

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

Related Questions

Transform continue direction 0 Answers

Finding difference between gameObject's x coordinate according to one object's transform 1 Answer

Why are my player's positions not being set correctly? 1 Answer

Raycast between TransformDirection and Vector3.Forward? 1 Answer

Difference between Vector.up and transform.up 2 Answers


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