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 /
This question was closed Jun 10, 2011 at 12:45 PM by biohazard.
avatar image
0
Question by biohazard · May 19, 2011 at 02:38 PM · rotationjavascript

[SOLVED]Possible Alternation of Transform.Rotate

I closed the other question due to lack of info.

The following is the case.

I have built a dashboard in unity, made movable pointers and made up algorithms for their degree rotations.

But i stumbled upon a huge problem.

I am reading my values (speed, rpm, engine temperature u get the deal) out of a TextAsset, and i need to make the pointer turn the other way when the car goes slower (DUH)...

Is there a Solution you could think of? If yes, pleaaaase let me know :)

EDIT : Turning into the other direction was solved by simply inserting a negative value (DERP). The only thing missing now is Stopping the pointer after he rotated the certain amount, saving the old value for checking and the algorithm for the car going slower :/

MOAR EDIT : Looked through the Scripting Reference, nothing there concerning the hold of a rotation in the way i need it... gonna be a real hassle to code this i guess

EVEN MOAR EDIT : Here's the Script

 function lese_datei() // Öffnen und Parsen der Datei.
 
     {
         Zeilen = CSVDatei.text.Split("\n"[0]); // Parsen an Zeilenendekennung
     
         for(i=4;i < Zeilen.length; i++)
     
             {
     
                 
                 Werte = Zeilen[i].Split(";"[0]);       // Parsen am Semikolon
                 
                 
                 var Geschwindigkeit_pos  = int.Parse(Werte[4]);
                 var Umdrehungen_pos = int.Parse(Werte[8]);
                 var Motorhitze_pos = int.Parse(Werte[9]);
                 
                 
                 Geschwindigkeit_rotation = (Geschwindigkeit_pos / 300.0) * 180.0;
                 Umdrehungen_rotation = (Umdrehungen_pos / 8000.0) * 240.0;
                 Motorhitze_rotation = Motorhitze_pos;
                 
   print("Zeilennummer:" + i + "\nGeschwindigkeit:"+Geschwindigkeit_pos+"\n"+"RPM:"+Umdrehungen_pos+"\n"+"Temperatur:"+Motorhitze_pos+"\n\n\n"+"Gradzahl speed:"+Geschwindigkeit_rotation+"\n"+"Gradzahl rpm:"+Umdrehungen_rotation+"\n"+"Gradzahl Temperatur:"+ Motorhitze_rotation);
                 yield WaitForSeconds(0.1); // lesetakt!
                 
                 
                 
             
             }
             
             Geschwindigkeit.transform.Rotate(0,Geschwindigkeit_rotation*Time.deltaTime,0); // HERE I WANT TO STOP AFTER REACHING THE VARIABLES VALUE
             
     
 
     }
 
 
 
 function Start() //wird NICHT einmal pro Frame aufgerufen, deswegen funktion hier rein!
 {
     lese_datei();
 }

Nobody can answer this? D:

SUM MOAR EDIT HURR :

I found out something extremely weird. If i add my calculated degree position to the X rotation of my pointer in the editor view, i get the right position. BUT! if i set it as X rotation in my script, it totally messes Up. I NEED to rotate it as Y rotation in my script to properly rotate it, but if i use it as Y rotation in the editor view it totally screws up.

Help?

:)

EDIT : Leaving this question till i leave the office, going to delete it then. i don't see a point in leaving this one up

Edit : SOLVED SOLVED AND EVEN MORE SOLVED!!!!

Here's the Guide to it, in case someone else got the same Problem!!!!

I've Created an Empty Game Object, and placed it right to a Pointer. Then, i made it the pointer's Parent.

Because empty GameObjects come completely without rotation, they are way more accurate than the already rotated pointers.

Meaning, if i make the empty GameObject the target of my rotation inside my script, The values will be way easier to interpolate, and also more accurate!!!

Thanks to graham Dunnett supporting me via skype.

I hope somebody can make use of this info as well

Comment
Add comment · Show 1
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 Herman-Tulleken · May 20, 2011 at 07:18 AM 0
Share

You should have have left your original question; now no-one know what it is about.

1 Reply

  • Sort: 
avatar image
1

Answer by demize2010 · May 20, 2011 at 08:47 AM

Rotations can be quite a pain... I'm not quite sure what your asking here but if your asking about how to set a limit on your rotation have you considered mathf.clamp?

http://unity3d.com/support/documentation/ScriptReference/Mathf.Clamp.html

Edit

Please don't bump questions man, people will help if they can. I'm afraid I don't speak German so I'm going to have to bow out of helping you at this stage.

My suspciain is that as you've * by Time.deltaTime you are calling this every frame. Using Mathf.Lerp is probably what your after.

Edit 2

Right try this:

Geschwindigkeit.transform.Rotate(0,Mathf.Lerp(Geschwindigkeit.transform.eulerAngles.y, Geschwindigkeit_rotation, Time.time),0);

Where it says Time.time is the time you want the rotation to occur in... see http://unity3d.com/support/documentation/ScriptReference/Mathf.Lerp.html for more

Comment
Add comment · Show 9 · 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 demize2010 · May 20, 2011 at 09:49 AM 0
Share

$$anonymous$$ay be an idea to post the script you have so far and specify where your problems are?

avatar image demize2010 · May 20, 2011 at 12:30 PM 0
Share

Are you calling this function from Update() every frame?

I'll add a sample of what you need to do...

avatar image demize2010 · May 20, 2011 at 12:34 PM 0
Share

as a co-routine?

avatar image demize2010 · May 20, 2011 at 12:37 PM 0
Share

this action will need to be called more then once, surely this function isn't just getting called once from Start() if its a readout update?

avatar image demize2010 · May 20, 2011 at 12:49 PM 0
Share

I'm not really following what your doing there or why but I'm sure you have your reasons, I've updated the script though so it uses eluer angles - this will have to be called multiple times either from a co-routine or update().

Show more comments

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Sorting through the same variable attached to several GameObjects from least to greatest, then returning an enum state based on that order 0 Answers

Randomly Generated Objects 1 Answer

Items with Statistics(such as attack damage) that actually effect the character? 2 Answers

How to rotate object on mouse click? 1 Answer

Need help with my script 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