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 NumbertenY · Jun 20, 2018 at 09:51 PM · quaternionquaternions

if(transform.rotation >= Quaternion.Euler(0, 0, -1f)) Error,If Quaternion >= Quaternion how come this doesn't work

Why can't I use the greater than or less than here and how can I fix it.

,My Script -

if(transform.rotation >= Quaternion.Euler(0, 0, -1f)) { FacingRight = true;

     } else {

         FacingRight = false;
     } 

The error is that you cant use >= or <= when using Quaternion So how can I fix that

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
3

Answer by Captain_Pineapple · Jun 20, 2018 at 10:36 PM

Hey there,

a quaternion is a 4-D Vector. It is kind of difficult to use a greater/smaller than operation on any kind of vector.

So assuming that you want to check if - let's say your player object - is facing left or right you could choose from some methods but that all depends on your exact setup. For example you could check for the euler angles that you get from your transform.rotation but this is kind of flawed if you do some more complex rotations.

Best would be if you specified a bit more information about your project.

Comment
Add comment · Show 4 · 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 NumbertenY · Jun 21, 2018 at 09:44 PM 0
Share

The specifics is that when the gun is rotated to the left I want to activate facingright = false

avatar image Captain_Pineapple NumbertenY · Jun 22, 2018 at 09:08 AM 0
Share

but rotated relative to what? to your player object? to the world coordinate system?

And most importantly: Are we talking about 2d or 3d?

If you could describe more details or attach an explaining picture that might prove helpfull.

avatar image NumbertenY Captain_Pineapple · Jun 23, 2018 at 02:41 AM 0
Share

It's a 2d game and heres some pictures alt text

script.png (15.1 kB)
forcomment.png (32.8 kB)
Show more comments
avatar image
0

Answer by sgthale · Jun 20, 2018 at 10:58 PM

If you want to see if an object is aiming higher than something. You gotta use local direction vectors not Quaternions, not Euler angles. Reason is that if you use Euler angles, the pitch and roll can represent the same "up" direction. So if you use a local direction vector, you can just check how high the y component is. Then go from there.

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

88 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

Related Questions

How to fix flipping Euler anlges? 0 Answers

[SOLVED] Rotation/angled offset in Quaternion.Lerp for a carried GameObject 2 Answers

Clock script with custom time not working 0 Answers

Addition Quaternion 0 Answers

Rotation by Quaternion Slerp problems 0 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