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 Luminaflare · Apr 13, 2012 at 03:56 PM · rotationmovementspeedlimittorque

Speed limit?

I'm creating a basic game for a college course and I'm having trouble with the controller script.

I have the script set to rotate a ball so you move around the level by rolling, I have the movement and rotation limited to set axis so it only moves along a 2D plane and doesn't rotate vertically to the camera view. (Z position is frozen, X and Y rotation are frozen)

I seem to be hitting a speed limit though, I can't get it to go faster than 3.5 according to the gui script I'm using to show me the speed.

Here's the GUI script and controller script.

 function OnGUI()
 { 
   GUI.Label(Rect(0,0,100,100), rigidbody.velocity.magnitude.ToString());
 }

 function Update () {
 if (Input.GetKey ("right")) {
 rigidbody.AddRelativeTorque (Vector3.back * 200);
 }
 if (Input.GetKey ("left")) {
 rigidbody.AddRelativeTorque (Vector3.forward * 200);
 }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by rutter · Apr 13, 2012 at 04:21 PM

If I had to guess, you might be hitting `Rigidbody.maxAngularVelocity`. Looks like you can change that value, although I don't know how far you can push it before running into problems.

You might try attacking this from another angle.

First, let's assume that PhysX is calculating your ball's movement based on more or less realistic circular kinematics:

 v := rω; //linear velocity equals radius times angular velocity
 a := rα; //linear acceleration equals radius times angular acceleration

Given the script reference's reported max angular velocity of 7, this implies that your ball's maximum velocity is seven times its radius. Since you're peaking at 3.5, that seems to indicate you're using a ball with radius 0.5? If so, this guesswork might have some merit.

If all of that is true, then you have two ways to increase your effective speed limit:

  • Increase the ball's max angular velocity

  • Increase the ball's radius

The first option is probably a quick change, so I'd try that first.

The second option might require that you rescale any levels or assets you've already created, but it's good to know that you probably have a fallback method.

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
avatar image
0

Answer by bodec · Apr 13, 2012 at 04:09 PM

your if statements need moved to a fixedUpdate function i tried to post the page i found the answer at but not sure how the page is in scripting manual.

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 AlucardJay · Apr 13, 2012 at 04:16 PM 0
Share

http://unity3d.com/support/documentation/ScriptReference/Rigidbody.AddRelativeTorque.html

@Lu$$anonymous$$aflare, try increasing the amount of force being applied. e.g.

 rigidbody.AddRelativeTorque (Vector3.back * 2000); // change 2000
 

or , make it a public var which you can then change in the Inspector while playing the scene (for testing) :

 public var myForce : float = 200;
     
 function OnGUI()
 { 
     GUI.Label(Rect(0,0,100,100), rigidbody.velocity.magnitude.ToString());
 }
 
 function Update () {
     if (Input.Get$$anonymous$$ey ("right")) {
         rigidbody.AddRelativeTorque (Vector3.back * myForce);
     }
     if (Input.Get$$anonymous$$ey ("left")) {
     rigidbody.AddRelativeTorque (Vector3.forward * myForce);
     }
 }
 
avatar image bodec · Apr 13, 2012 at 04:17 PM 0
Share

thank you for posting the page

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

7 People are following this question.

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

Related Questions

How to limit the force from player input without limiting speed 2 Answers

Speed of player depends on angle of rotation 1 Answer

Limiting rotatioal speed for targeting 1 Answer

Object doesn't turn at the desired rate 1 Answer

How to add a velocity limit to an object with rigibody addforce? 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