Search Unity

Rigid body marble on terrain

Discussion in 'Scripting' started by leolicos, Dec 1, 2010.

  1. leolicos

    leolicos

    Joined:
    Dec 1, 2010
    Posts:
    28
    Hello, I'm new to unity and I'm really having trouble getting a simple "marble madness" type simulation running. I have a couple issues:

    It appears as though the gravity force is really small; the ball never falls at a fast enough rate. When I position the ball in the air, set the mass to say 1000 and run the game, the ball falls really slow.

    Next, I'm not sure if it's because of that or something else, but when I move the ball with the control keys and add torque force to spin it to get it to move, the ball either doesn't move fast enough, or if I add a lot of force, it moves so fast that it spins really fast before the friction allows it to actually move the ball. Even when I have a physics material on the ball and the terrain both dynamic and station friction set to 1, I get the same results.

    What seems to be the problem??
     
  2. hallamasch

    hallamasch

    Joined:
    Nov 29, 2010
    Posts:
    153
    I am not to experienced with the physic system yet, but I read in the Documentation, about the drag and angular drag coefficients.
    Check here, this might be related to your problem.

    http://unity3d.com/support/documentation/Components/class-Rigidbody.html


    Drag How much air resistance affects the object when moving from forces. 0 means no air resistance, and infinity makes the object stop moving immediately.

    Angular Drag How much air resistance affects the object when rotating from torque. 0 means no air resistance, and infinity makes the object stop rotating immediately.
     
  3. leolicos

    leolicos

    Joined:
    Dec 1, 2010
    Posts:
    28
    I found the problem. I needed to add more gravity, but I couldn't find where to change the gravity that unity uses, so I just added a ConstantForce component and added it there. Is that the main approach people use? Or are there others? Also, where do I change the value of gravity that unity uses when "use gravity" is checked in a collider?
     
  4. hallamasch

    hallamasch

    Joined:
    Nov 29, 2010
    Posts:
    153
    Well like I said up there, read up on the Drag Coefficient.

    Gravity is a constant.(Well actually not, but think of it as a constant to simplefy this)
    The Speed at which objects fall, is dependant on the mass and air resistance (shape) of an object.

    For a quick physics background, check this out:
    http://www.grc.nasa.gov/WWW/K-12/airplane/falling.html

    Adding a constant force is 1 way of solving the problem, but make sure that it doesn't mess up the physics calculation.
     
    Last edited: Dec 2, 2010
  5. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Your issue is one of scale, and modifying gravity is the correct way to go about it. Look in the menu for ProjectSettings->Physics for the value you need to adjust according to your model scale.
     
  6. hallamasch

    hallamasch

    Joined:
    Nov 29, 2010
    Posts:
    153
    If you don't like the fall dynamics of your airplane you don't go ahead and change the gravitational force of the earth.
    No you build a more aerodynamic airplance, with less air resistance. (*Hint* you influence the air resistance of your object)

    Bye changing the Gravitational force, your messing with the underlying physics calculation which can lead to unexpected behaviour.