x


changing gravity for one object.

so i have a car in my game..... and i want it to have more gravity then other objects.

i have tried using

rigidbody.AddForce(0,-25,0); 

but it does not work.. and i have tried the constant force component but it has the same results.

what happens is it moves down really slowly even when i have it set to -25 or something.

i have tried disabling the car script but it does the same thing.

so i thought that it might be something to do with the wheel colliders....

any thought on how to fix this would be nice.....

thanks

more ▼

asked Aug 05 '10 at 05:54 PM

3dDude gravatar image

3dDude
2.6k 65 76 103

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

3 answers: sort voted first
Function FixedUpdate()
    {
    rigidbody.AddForce(Physics.gravity * rigidbody.mass);
    }

This means 2g for that rigidbody. Moreover, if now you disable rigidbody's "Use Gravity" you'll get the normal 1g results.

more ▼

answered Aug 16 '10 at 11:24 PM

Edy gravatar image

Edy
637 2 5 17

thanks a lot I'll try that

Aug 16 '10 at 11:27 PM 3dDude
(comments are locked)
10|3000 characters needed characters left

Two quick things you can check:

  • Physics is affected by scale. A person jumping off a building takes longer to hit the ground than a lego man falling off a box at the same relative scale. If your scale is huge, it will make your physics appear in slow motion. Check how many units your car is long (ideally 4 or thereabouts).

  • Time step / Time Scale. Both found under Settings -> Time. They will affect the overall speed of your simulation, but it's worth playing around with these and the forces applied to your car.

Have you tried altering global gravity anyway? What undesirable behaviour (if any) does it cause elsewhere?

more ▼

answered Aug 05 '10 at 07:05 PM

Novodantis 1 gravatar image

Novodantis 1
1.7k 14 22 40

well i have tried the global gravity but it made everything go to fast but i think the only thing that needs to be faster is the car..... the timeScale is set to 1 and the timeStep is set to 0.02.... and everything is the right scale EG main character is 2 meters tall the car is scaled relative to the player.

Aug 06 '10 at 01:51 PM 3dDude

It is odd how AddForce in the minus y doesn't make a difference. What's the mass of the car? You might also want to try changing the force mode of that force, and Debug.Log out the line after to make sure it's being applied. You can check up Force Modes here: http://unity3d.com/support/documentation/ScriptReference/ForceMode.html

Aug 07 '10 at 06:20 PM Novodantis 1
(comments are locked)
10|3000 characters needed characters left

ForceMode.Force (default) incorporates mass, so you'd have to multiply the force by mass to make it work like gravity.

ForceMode.Acceleration works regardless of mass, just like real gravity. This is what Rigidbodies use when UseGravity is checked.

more ▼

answered Nov 29 '10 at 08:09 PM

Tuah gravatar image

Tuah
153 22 23 29

(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:

x1798
x1095
x464
x418

asked: Aug 05 '10 at 05:54 PM

Seen: 6287 times

Last Updated: Aug 05 '10 at 05:54 PM