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 /
This question was closed Jun 01, 2016 at 10:17 AM by Psyco92 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Psyco92 · Nov 15, 2013 at 10:43 AM · javascript

Debug states its true but if doesnt trigger.

     Debug.Log(this.transform.localEulerAngles+" | "+weaponButtons.camEuler);
     if(this.transform.localEulerAngles == weaponButtons.camEuler){    
         Debug.Log("Check");    
         var weaponV4 : Vector4 = profileScript.ModWeapon(selectedWeaponType, "Return", 0);        
         Debug.Log(weaponV4);
         weaponButtons.damageText.text = "Damage "+weaponV4.x;
         weaponButtons.rangeText.text = "Range "+weaponV4.y;
         weaponButtons.clipSizeText.text = "Clip Size "+weaponV4.z;
         weaponButtons.reloadRateText.text = "Reload Rate "+weaponV4.w;
     }    

this is running in the Update on a camera

The Debug shows that my local euler is 0, 180, 0 and that the weaponButtons.camEuler is 0, 180, 0.

the if statement is not running... the "Check" debug is not running...

How can i fix this?

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

  • Sort: 
avatar image
2
Best Answer

Answer by tanoshimi · Nov 15, 2013 at 10:49 AM

transform.localEulerAngles (and, I assume, your weaponButtons.camEuler variable) are vectors of floating point variables, and it's never a good idea to check for equality of floating point numbers.

Instead, check whether the difference between the components is less than a certain acceptable margin of error, or perhaps compare the dot product of the two vectors to see whether it's sufficiently close to 1.

Comment
Add comment · Show 1 · 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 Psyco92 · Nov 15, 2013 at 11:24 AM 0
Share

thank you forgot about that :P noob error

Follow this Question

Answers Answers and Comments

18 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

Related Questions

A node in a childnode? 1 Answer

Cube terrain with perlin noise 1 Answer

UnityEngine has no appropriate version problem 1 Answer

Singletons in music script? 2 Answers

2.5D ledge hang with javascript 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