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 Hellwalker · Apr 28, 2010 at 07:11 PM · physicsballrolling

moving and jumping ball using physics

hi, I know how to move static objects, with transforms. but how can I move ball with physics. I mean I click forward button[w] and ball rolls forward following terrain. when I click jump[space] it jumps. also can I make ball bounce up and down all the time? I got this effect while messing with physics components and kind of liked it. (very relaxing to watch xD)

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

Answer by StephanK · Apr 28, 2010 at 10:00 PM

To make the ball bounce all the time set its physics material bounciness to 1 and the bounce combine to maximum. To "steer" the ball with physics you will need to either apply forces to its rigidbody or set its velocity directly. Both can be done with member functions of the rigidbody component, which you can look up in the scripting reference.

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 Random Indie · Apr 29, 2010 at 05:35 AM 0
Share

I would suggest using forces for steering and only use velocity for jumping or instantanious speed boosts.

avatar image Hellwalker · Apr 29, 2010 at 07:38 PM 0
Share

Thx I got it working

avatar image
1

Answer by Waz · May 01, 2010 at 10:35 PM

You'll probably want to apply torque to rotate the ball. Then its friction with the surface it is on will convert that into motion. This works when applied to a sphere:

function FixedUpdate() {
    var torque = Vector3(Input.GetAxis("Vertical"), 0, -Input.GetAxis("Horizontal"));
    torque = Camera.main.transform.TransformDirection(torque);
    torque.y = 0;
    rigidbody.AddTorque(torque.normalized*speed);
}

If you instead apply the force directly to the ball, it might seem to work similarly, because the friction with the contact surface will cause it to roll (the inverse of the above). However, on, say, ice, it will accelerate faster (and not roll much). Of course, that might be what your game requires.

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 Chimera3D · May 02, 2012 at 02:33 AM 0
Share

Thanks bro!

avatar image ebad · Oct 01, 2012 at 04:12 PM 0
Share

Thanks Warwick! But I have a problem with this which is that the ball doesn't stop after applying the AddTorque until it reaches a collider. Given the friction and gravity, It's supposed to lose the energy after a while and stop, but it don't! Could you please help in this issue as well? Thanks.

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

1 Person is following this question.

avatar image

Related Questions

How to roll a ball with moving platform. 1 Answer

rolling ball is a child that needs to be steered by parent 1 Answer

Ball rolling on platform 0 Answers

How to make a ball that can roll? 2 Answers

Create a "free" rolling ball controlled by player 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