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 conguerror · Jun 20, 2021 at 03:00 PM · cameratransformforwardworld spacerelative movement

Get Camera's Vector(1,01)

So I have a code that returns world forward, world (1,0,1) and etc. But I don't know how to get camera's (1,0,1) and etc. Vectors. Please help

 Vector3 SwipeAngleTest(float angle)
       {
         if (angle < -157.5 || angle > 157.5)
         {
             //Debug.Log("Left");
             return -Vector3.right;
         }
         else if (angle < -112.5)
         {
             //Debug.Log("Down Left");
             return new Vector3(-1, 0, -1);
         }
         else if (angle < -67.5)
         {
             //Debug.Log("Down");
             return -Vector3.forward;
         }
         else if (angle < -22.5)
         {
             //Debug.Log("Down right");
             return new Vector3(1, 0, -1);
         }
         else if (angle < 22.5)
         {
             //Debug.Log("Right");
             return Vector3.right;
         }
         else if (angle < 67.5)
         {
             //Debug.Log("UPRight");
             return new Vector3(1, 0, 1); 
         }
         else if (angle < 112.5)
         {
             //Debug.Log("Up");
             return Vector3.forward;
         }
         else
         {
             //Debug.Log("up left");
             return new Vector3(-1, 0, 1); 
         }
     }
Comment
Add comment · Show 11
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 Tinglee82 · Jun 20, 2021 at 03:51 PM 0
Share

I'm can't quite understand this "But I don't know how to get camera's (1,0,1)". Were you not able to arrive at the else statement that should log Vector3(1, 0, 1)? Or could you provide more context to your question?

avatar image conguerror Tinglee82 · Jun 20, 2021 at 03:58 PM 0
Share

@Tinglee82 There is transform forward and right,right? That state the local forward. But how do I get transform's diagonal axis? like up and right(vector(1,0,1)) of relative forward

avatar image Tinglee82 conguerror · Jun 20, 2021 at 04:06 PM 0
Share

By "transform's diagonal axis", are you referring to the forward direction of the camera? Sorry I still can't understand your use case, or at least which parts of your code are not working.

Show more comments

1 Reply

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

Answer by conguerror · Jun 20, 2021 at 05:32 PM

return (transform+new Vector3(1,0,1)).Normalize()

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

207 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 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

Convert Unity position to Maya position 1 Answer

SmoothFollow script facing forward 1 Answer

[Solved] How to move the camera in the forward axis 1 Answer

Setting a cube to be exactly size of intersecting camera view plane 1 Answer

Mathf.Abs and How to play animation only if x,z transform has changed by 0.2 units ? 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