x


Cylinders running downhill. Gravity is not enough.

I have a curved ground (model) in my scene working as a hill race track. I have added several cylinders and applied rigid bodies to make them move (roll) down the track. What is the best way to get the cylinders to move the way I want them to move? As it is right now, the cylinders are moving to slow. I want them to speed up when moving down the hill. How can I achieve this?

My solution right now:

function Start()
{
    rigidbody.AddTorque(0, 0, 200 * direction);
}

alt text

more ▼

asked Jan 12 '11 at 07:58 PM

Mattias Wargren gravatar image

Mattias Wargren
56 17 20 25

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

I like rockets! (ConstantForce) Woosh! Just make sure to angle them correctly so as to not shoot your barrels off into space. :)

Link --> ConstantForce

more ▼

answered Jan 12 '11 at 08:26 PM

Goody! gravatar image

Goody!
516 24 31 46

That seems more like a workaround than a solution (and in any case, it doesn't really correlate with the behavior the OP described).

Jan 12 '11 at 08:34 PM Jesse Anders

This might work well. I used rigidbody.AddTorque(0, 0, 100 * direction); in the Start function but your solution is even better.

Jan 12 '11 at 08:37 PM Mattias Wargren

@Jesse Anders Could you please explain?

Jan 12 '11 at 08:38 PM Mattias Wargren

The impression I got was that you wanted the cylinders to roll down the hill due to gravity in a realistic fashion, in which case applying a linear force (or even a torque) would be a bit of a workaround. But, if it looks right to you and gives you the results you're after, that's probably all that matters.

Jan 12 '11 at 08:47 PM Jesse Anders

Constant forces are pretty easy to do if you want to try it out to see if it does what you want. Select your barrel in the Scene View then all a constant force to it via Component/Physics/ConstantForce. Then just fiddle with the variables to see if it'll do what you want. Have fun. :)

Jan 12 '11 at 08:49 PM Goody!
(comments are locked)
10|3000 characters needed characters left

This may be too obvious, but have you tried playing around with different physics materials? (Also, make sure the masses of your objects are in proportion to the scale of the scene and your gravity settings.)

more ▼

answered Jan 12 '11 at 08:11 PM

Jesse Anders gravatar image

Jesse Anders
7.3k 7 17 48

(comments are locked)
10|3000 characters needed characters left

Aside from scale, one cause of too-slow rolling is not having a high enough max angular velocity in the physics settings.

more ▼

answered Jan 12 '11 at 08:16 PM

Eric5h5 gravatar image

Eric5h5
80.2k 41 132 519

What is a good value for max angualr velocity and what are the consequences of altering the value?

Jan 12 '11 at 08:41 PM Mattias Wargren

Just try things out. Save your project under a different name if you are worried about messing it up, and try things. Make a new barrel with super low angular velocity and see what happens, attach a constant velocity to another and see what happens, hell, set off an explosion next to one and see if it does what you want. Most of the stuff mentioned in the answers don't have anything to do with scripting and are pretty much, plug, play, and experiment. :)

Jan 15 '11 at 11:39 PM Goody!
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1787
x459
x20

asked: Jan 12 '11 at 07:58 PM

Seen: 1114 times

Last Updated: Jan 12 '11 at 08:54 PM