Alright, I'm a complete newbie with Unity, and I thought you guys might be able to help.
At the moment, I'm making something along the lines of a small test game, where the player is able to control a ball or marble. I added a rigidbody to the ball, and when i started to script it, I ran into a dead-end.
At first I used rigidbody.AddForce() but it seemed unrealistic.
I tried to get it to move by using rigidbody.AddTorque(), but the ball doesnt seem to roll fast enough. I tried multiplying mainly, but no matter how high i put the numbers, the speed remained the same.
I cant find any other ways to do this. Is there something im missing?
have done this feature? any example code can be show ? many thanks !
Answer by Ashkan_gc
Dec 29, 2009 at 07:34 AM
rotation speed is limited by a setting in physics settings.
just go to edit/project settings/physics and change the value of max angular velocity. don't set it to a really high value because it can produce errors.
i use this code for rolling and it works well
if (rigidbody.velocity.magnitude < maxspeed) rigidbody.AddForce (Input.GetAxis ("Mouse X")*speed/ratio, 0, Input.GetAxis("Mouse Y")*speed);
i defined maxspeed, ratio and speed as variables in top of my code. i don't copy whole code because it's C# code and you don't use it. it has many other stuff too. the ratio variable is the ratio between z axis and x axis movements.
the movement is natural even with max angular velocity of 7 (default). don't change the value if you don't have to do so. it can result in a ball that pass other colliders.
Answer by Goody!
Dec 15, 2009 at 05:14 AM
If you are using the Iphone version of Unity you can check out the Unity demo Roll-A-Ball:
It's a simple roll-the-marble-past-the-holes type of game.
Even if you aren't using Iphone you may be able to pry some useful tidbits out of it. :)
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
2 People are following this question.
The name 'Joystick' does not denote a valid type ('not found')
Strange Rigidbody Behavior
Raycasting from the sides of a GameObject
Show "Score:5" on my screen, how?
RigidBody Script Conflict