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 sketchers1 · Sep 08, 2011 at 03:14 AM · rotationguispacegui.box

GUI Display

So i am making a Space Game In our Solar System for science. I have a rotater script that makes each planet orbit around the sun. I want to have their speeds Displayed in a GUI Box in the corner. This is the script:

 var xSpeed : float = 1;

var ySpeed : float = 1; var zSpeed : float = 1;

var manual : boolean = false;

function Update () {

 if( !manual )
 {
 
     transform.RotateAround( transform.position, Vector3.right, ySpeed * Time.deltaTime );
     transform.RotateAround( transform.position, Vector3.up, xSpeed * Time.deltaTime );
     transform.RotateAround( transform.position, Vector3.forward, zSpeed * Time.deltaTime );
     
 }
 else
 {
     
     if( Input.GetAxis("Horizontal") != 0 )
     {
         
         transform.RotateAround( transform.position, Vector3.up, Input.GetAxis("Horizontal")*xSpeed * Time.deltaTime );
         
     }
     
     if( Input.GetAxis("Vertical") != 0 )
     {
         
         transform.RotateAround( transform.position, Vector3.right, Input.GetAxis("Vertical")*ySpeed * Time.deltaTime );
         
     }
     
 }
 

}

Is there a way to show the X speed for each planet? they each have this script with a different x-rotation Value

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 GuyTidhar · Sep 08, 2011 at 05:35 AM 0
Share

You just wish to show the xSpeed variable value on the screen?

avatar image sketchers1 · Sep 08, 2011 at 09:59 AM 0
Share

yes, I only wish to show the x speed, as the others are zero

2 Replies

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

Answer by barnabasborn.du · Sep 08, 2011 at 06:23 AM

I think if you use the OnGUI function you should be able to get it set up for how you want it.

void OnGUI() { GUI.Box(new Rect(50, 50, 150, 20), "Planet Name's Speed:" + xSpeed); }

the Rect function goes (x position, y position, linewidth, lineheight), add text in " "'s here and to display you rvariables use the + before it like shown. hope this helps.

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 sketchers1 · Sep 08, 2011 at 09:59 AM 0
Share

I think I will try this. Thanks!

avatar image
0

Answer by sketchers1 · Sep 08, 2011 at 10:15 PM

So, I tried This:

var xSpeed : float = 1;

var ySpeed : float = 1; var zSpeed : float = 1;

var manual : boolean = false;

function Update () {

if( !manual ) {

 transform.RotateAround( transform.position, Vector3.right, ySpeed * Time.deltaTime );
 transform.RotateAround( transform.position, Vector3.up, xSpeed * Time.deltaTime );
 transform.RotateAround( transform.position, Vector3.forward, zSpeed * Time.deltaTime );

} else {

 if( Input.GetAxis("Horizontal") != 0 )
 {

     transform.RotateAround( transform.position, Vector3.up, Input.GetAxis("Horizontal")*xSpeed * Time.deltaTime );

 }

 if( Input.GetAxis("Vertical") != 0 )
 {

     transform.RotateAround( transform.position, Vector3.right, Input.GetAxis("Vertical")*ySpeed * Time.deltaTime );

 }

}

} function OnGUI () { (GUI.Box(Rect(20, 40, 80, 80), "Jupiter:" + xSpeed)); }

And it worked... Now, For my presentation, I want the number to fluctuate, So even though the x-speed for my planet is 13.07, I want it to have a constant fluctuation between 13.02-13.22 Is there a way to do this? and I would want the fluctuation to be constant..

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Apply a Rotation in World Space based on Quaternions 2 Answers

gimble lock and rotation problem 2 Answers

Scaling a GUI element to fit it's contents 0 Answers

Convert world space to GUI Rect? 5 Answers

Displaying Z Rotation through script 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