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 RC_creeper · May 07, 2012 at 02:16 AM · rigidbodysphererollfaster

Makeing a sphere with rigidbody.AddTorque roll faster

I am trying to make a ball rolling game, but when i use the code below the Sphere rolls slowly.

pragma strict

var tilt : Vector3 = Vector3.zero; var jumpSpeed: float = 8; var speed : float; var fuerza = 10; private var circ : float; private var previousPosition : Vector3;

@script RequireComponent(Rigidbody) function Start() { //Find the circumference of the circle so that the circle can be rotated the appropriate amount when rolling circ = 2 Mathf.PI collider.bounds.extents.x;
previousPosition = transform.position;

}

function Update () { tilt.x = -Input.acceleration.y; tilt.z = Input.acceleration.x;

 rigidbody.AddTorque (tilt * speed * Time.deltaTime);
 
 if (Input.GetKey("up"))
 rigidbody.AddTorque (Vector3(0, 0, fuerza));

if (Input.GetKey ("right")) rigidbody.AddTorque (Vector3(fuerza, 0, 0));

if (Input.GetKey ("down")) rigidbody.AddTorque (-Vector3(0, 0, fuerza));

if (Input.GetKey ("left")) rigidbody.AddTorque (-Vector3(fuerza, 0, 0));

     if (Input.GetKeyDown (KeyCode.Space)){
     rigidbody.velocity.y = jumpSpeed;
     
     
 }
 

}

function LateUpdate() { var movement : Vector3 = transform.position - previousPosition;

 movement = Vector3(movement.z,0,  -movement.x);
 
 transform.Rotate(movement / circ * 360, Space.World);
 
 previousPosition = transform.position;    
 

}

Any simple way to make the sphere roll faster? Also i cant use Rigidbody.AddForce sence I am using custom Gravity.

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
2
Best Answer

Answer by Chimera3D · May 07, 2012 at 03:02 AM

Yeah, I had trouble with this too. Go to Edit-> Project Settings -> Physics and Increase the max angular velocity. I don't think there is any way to make the ball roll faster in short bursts, even if you increase the max angular velocity during a getKey. :/ Also this affects all rolling objects so keep that in mind.

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 Seyyed · May 09, 2013 at 10:03 AM 0
Share

Works perfect! tnx a lot!

avatar image Huacanacha · Dec 31, 2013 at 12:59 AM 0
Share

Note that you can override the global maxAngularVelocity by setting it on a RigidBody.

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

Roll a ball around with Mobile Standard Assets First Person Controls and make image look decent on sphere. 2 Answers

Sphere moves randomly after adding rigidbody! 0 Answers

Rigidbody Sphere slides around when rotating. 0 Answers

Rigidbody sphere slows down quickly 2 Answers

How to make a "pressure sensor" of sorts that when rolled over switches to another scene 2 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