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
0
Question by Redmoth · Jul 17, 2012 at 05:44 PM · rotationjavascriptangleplane

How to determine if my plane is facing downards (unityscript)

Hi, I have a plane build, and I want it to accelerate when it faces downwards through unityscript. Using local rotation isnt reliable, since it changes all the time. Is there a way of using global rotation to determine if it is facing downwards?

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
1
Best Answer

Answer by Paulius-Liekis · Jul 18, 2012 at 09:55 AM

Global rotation is returned by transform.rotation.

You can check if it's faceing downwards by checking transform.forward.y. It should be: 0 - when plane is leveled and -1 when facing downwards.

Comment
Add comment · Show 7 · 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 Redmoth · Jul 18, 2012 at 06:20 PM 0
Share

Thanks for the quick answer! will it return -1 only if the plane faces EXACTLY downwards or if it starts facing downwards? I want my plane to gain velocity depending on how much it faces downwards

avatar image Paulius-Liekis · Jul 18, 2012 at 09:15 PM 0
Share

if (transform.forward.y < 0) factor = $$anonymous$$athf.Abs(transform.forward.y);

avatar image Redmoth · Jul 18, 2012 at 09:18 PM 0
Share

What does that mean? Thats gradually?

avatar image Paulius-Liekis · Jul 18, 2012 at 09:23 PM 0
Share

Yes, factor will be propotional to how much it is facing downwards

avatar image Redmoth · Jul 18, 2012 at 09:24 PM 0
Share

Thanks very much!

Show more comments
avatar image
1

Answer by whydoidoit · Jul 18, 2012 at 06:32 PM

Try this:

  if(Vector3.Dot(transform.up, Vector3.up) < 0)
  {
      //Facing downwards
  }
Comment
Add comment · Show 2 · 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 Paulius-Liekis · Jul 18, 2012 at 09:47 PM 0
Share

This is correct if we're talking about Unity Plane primitive. It is not correct if we're talking about general (air)plane model which is oriented in Z direction.

avatar image whydoidoit · Jul 19, 2012 at 11:02 AM 0
Share

Yeah comedy answer that I had it checking the Z and then I flipped it when I looked at the title of the questions :)

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

6 People are following this question.

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

Related Questions

Rotate floor plane in-game via C# script 1 Answer

Find corner of rotated plane 1 Answer

Bone Rotation on X (or any) axis Issues 1 Answer

Rotating sprite through touch (storing current rotation) 0 Answers

How can I multiply the rotation of a mirrored object? 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