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 thenachotech1113 · Jan 15, 2013 at 03:34 AM · rotatemaxaddrelativeforce

how do i put a max to rigidbody.AddRelativeTorque

hey im trying to simulate a plane, but when i try to make it rotate it starts to go faster and faster(i know the AddRelativeTorque does that), but i want to add a max and i cant think of a way to do this. here is the code i used:

 @HideInInspector
 var xRotation : float;
 @HideInInspector
 var yRotation : float; 
 @HideInInspector
 var zRotation : float; 
 
 var maxRotation : float = 7;
 var rotSensibility : float = 7;
      
 function Update(){
     
      xRotation = Input.GetAxis("Vertical") * rotSensibility * Time.deltaTime;
      yRotation = Input.GetAxis("Horizontal") * rotSensibility * Time.deltaTime;
      zRotation = Input.GetAxis("Roll") * rotSensibility * Time.deltaTime;
      
      rigidbody.AddRelativeTorque(xRotation, yRotation, zRotation);
      
      if (Input.GetAxis("Horizontal") == 0){
        rigidbody.AddRelativeTorque(xRotation, 0, zRotation);  
      }
      if (Input.GetAxis("Vertical") == 0){
        rigidbody.AddRelativeTorque(0, yRotation, zRotation);
      } 
       if (Input.GetAxis("Vertical") == 0){
        rigidbody.AddRelativeTorque(xRotation, yRotation, 0);
      }
     
     }
 
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
1
Best Answer

Answer by Karsnen_2 · Jan 15, 2013 at 02:31 PM

I am not sure of what you mean by 'put a max to Rigidbody.AddRelativeTorque'.

Whatever you might as the highest optimal speed on the gameplay is the max. What You See is What You Need. So from you code above, you have used

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

twice and no matter what input you give in,

  rigidbody.AddRelativeTorque

is going to run twice as you called it twice. You might have to consider to it.

As for you, try to adjust rotSensibility as much as possible to get the maximum you think you need. Then just stop there. It is your MAXIMUM.

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 thenachotech1113 · Jan 15, 2013 at 04:45 PM 0
Share

thanks, sorry for not being so clear

avatar image Karsnen_2 · Jan 15, 2013 at 08:48 PM 0
Share

No Problem if you were able to find the solution. Dude, can you tick the answer if it had helped to solve your problem.

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rigid body rotation question 1 Answer

Camera rotation around player while following. 6 Answers

Min, Max Rotation Help 2 Answers

Rotate.around to specific point 1 Answer

LookAt once 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