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 digs · May 11, 2014 at 07:45 PM · rotationissue

Strange rotation problem? need to remove then re-Add Component

hello, I'm creating a side scroller - when the character gets to the end of a level, the camera changes to a top down view of the Boss Area - all of this works great, except in order for my character to fire projectiles at the mouse (using MouseLookAt script), I have to rotate the players mesh -90 degrees as soon as he enters the play area

 public class PlayerMeshRotation : MonoBehaviour 
 {
     public int useLookAt;
 
     void Start ()
     {
         useLookAt = 0;
     } 
     
     void Update()
     {
         useLookAt = PlayerMovement.lookAt;
 
         while(useLookAt == 1)
         {
             transform.Rotate (0,-90,0);
             break;
         }
         if(useLookAt == 1)
         {
         useLookAt = 2;
         }
     }
 
 }

However, the first time I load the scene, this doesn't work - I have to "Remove Component" (that script), then "Add Component" (that same script) - resetting the script does nothing. Any ideas whats happening?

Comment
Add comment · Show 2
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 Scribe · May 12, 2014 at 12:58 PM 0
Share

There's not really enough information here to help easily, what is Player$$anonymous$$ovement.lookAt? You are never setting it but you seem to always want it to be 2 if it returns 1 but why not then just recode whatever asked to be 2 to be 1.

I'm not sure this is your problem but I don't like the look of that while loop, it is an infinite loop as you are not changing useLookAt within the loop. I presume the only reason it hasn't crashed unity is because it's in Update so it is recalled each frame anyway...

You aren't even using useLookAt to do anything in this script so what is the point of it?

avatar image Sprawl · May 12, 2014 at 02:16 PM 0
Share

I think this is just a basic version of what his script looks like.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ardmark · May 12, 2014 at 02:47 PM

Are you setting PlayerMovement.lookat in the Inspector? I'm wondering if PlayerMovement.lookat is being changed somewhere before loading the scene (or perhaps it is retaining it's value from the previous scene), but if you have it set to 1 in the Inspector then reloading the component would allow the script to work? Just a thought.

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

23 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

Related Questions

Quaternion Rotation On Specific Axis Issue 0 Answers

iTween - Rotation Add get's uneven after several rotations 2 Answers

Weird issue with clamp on Rotation 1 Answer

Blender Mesh rotation 3 Answers

Child lossyScale changes after setting localRotation 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