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 SemyonSichov · May 10, 2019 at 12:52 AM · scripting problemnavigation

enum variables change only one time

Hi. I'm working on 2,5D game, 2D sprites in ortographic 3D enviroment with XCOM-like camera (fixed angle of view and Q-E rotation with step of 90 degrees). Trying to create some sort of global coordinate system to properly switch side of sprites, but stuck with one trouble: in play mode, enum values for directions (north, east, south, west) changes only one time (tested with Debug.Log). Every value leaves its debug text only one time, and don't react after that. But I need to change them constantly when I rotate a camera for translate prore value of observation side for sprites. Script attached to main camera focus point (blank object on the ground level). Here is my code:

 public class DirectionsScript : MonoBehaviour
 {
 public enum Direction {North, East, South, West};
 Direction currentDir;
 
 void Update()
 {
     currentDir = Direction.North;
     
     if (transform.rotation.eulerAngles.y > 359 & transform.rotation.eulerAngles.y < 1)
     {
         currentDir = Direction.North;
         Debug.Log ("North");
     }
     
     if (transform.rotation.eulerAngles.y > 89 & transform.rotation.eulerAngles.y < 91)
     {
         currentDir = Direction.East;
         Debug.Log ("East");
     }
     
     if (transform.rotation.eulerAngles.y > 179 & transform.rotation.eulerAngles.y < 181)
     {
         currentDir = Direction.South;
         Debug.Log ("South");
     }
     
     if (transform.rotation.eulerAngles.y > 269 & transform.rotation.eulerAngles.y < 271)
     {
         currentDir = Direction.West;
         Debug.Log ("West");
     }
 }
 }

Sorry for broken english, it's not my native language. Thanks for advance.

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

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

Answer by Bunny83 · May 10, 2019 at 12:54 AM

You probably have enabled collapse in your console window. Deactivate it. However if collapse is enables there should be a counter on the right of each message telling you how many have occurred already. If you need to know the exact order of the individual messages you have to disable collapse.

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 Bunny83 · May 10, 2019 at 01:01 AM 0
Share

Note that your title is misleading as your issue is not related to the enum at all. You check the eulerangles and based on that you print a hardcoded debug text. If you take out the whole enum stuff nothing will change in regard to the printed text in the console.


Also note that using euler angles can cause issues since euler angles do not have a unique representation of a certain orientation. The next issue is you narrowed your "active areas" down to a 2° window for each direction. This is a quite narrow range. If you control the rotation with the mouse you can easily skip over that range and of course the direction won't update in this case.

avatar image SemyonSichov · May 10, 2019 at 03:46 AM 0
Share

Thanks, dude, that's really be a collapse button. When I turn it off - all start to works as I thought. ... Camera moves with Q and E press, for fixed steps and angle 90 degrees. Not by mouse. Even with a fixed value in code it works correctly.

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

182 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

Related Questions

Moving & Setting navigation nodes in different Functions 0 Answers

Array GameObjects Destinations NavMeshAgent 2 Answers

I need help with unity navigation networking 1 Answer

GameObject's Navigation Area from script 0 Answers

Setting NavMesh from NavMeshTriangulation or Mesh 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