x


AddForce doesn't work?

Why won't this script work? It seems perfectly reasonable to me.

private var canKill = false;

function Destroy () {
    rigidbody.isKinematic = false;  
    rigidbody.AddForce(0,10,0); 
    canKill = true;
}


function OnBecameInvisible() {
    if (canKill) {
        Destroy(gameObject);
    }
}

When I call Destroy(), my object should jump in the air then disappear when my camera doesn't see it, but it doesn't jump. Is it because I'm calling it too soon after setting the rigidbody to non-kinematic?

Thanks - Elliot

more ▼

asked Jan 28 '11 at 04:56 PM

e.bonneville gravatar image

e.bonneville
5.7k 100 116 165

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

1 answer: sort voted first

No, it's because your force is too small. Use a different ForceMode. ForceMode.Force is designed to be used in FixedUpdate, as it is premultiplied by Time.fixedDeltaTime.

more ▼

answered Jan 28 '11 at 05:10 PM

Jessy gravatar image

Jessy
15.6k 72 95 196

Ah, okay. Thank you.

Jan 28 '11 at 05:29 PM e.bonneville
(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:

x1794
x244

asked: Jan 28 '11 at 04:56 PM

Seen: 1708 times

Last Updated: Jan 28 '11 at 04:56 PM