x


Unity help with OnTrigger Enter gravity turn off

Hey guys and girls,

Simply enough I'm having a little trouble with this part of a script, as simply enough I don't quite understand javascript just yet. What i'm trying to do is OnTriggerEnter I want the gravity applied to this object via its rigidbody to be tunred on... however it's not quite there.

function OnTriggerEnter(otherObject: Collider){
    if(otherObject.gameObject.tag == "switch1"){
    var block1 = GameObject.FindWithTag ("block1");
    block1.attachedRigidbody.useGravity = true;
    }
    }

Any ideas would be lovely.

Thanks!

more ▼

asked Dec 15 '11 at 09:18 PM

BobbleHead gravatar image

BobbleHead
189 29 48 61

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

1 answer: sort newest

try getting rid of "attachedRigidbody" and just using "rigidbody".
EDIT: and if you're trying to change the gravity on the object that this script is on, then don't bother with the "block1" stuff... just use "rigidbody.useGravity"

more ▼

answered Dec 16 '11 at 01:27 AM

Lo0NuhtiK gravatar image

Lo0NuhtiK
3.5k 1 9 39

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

x462
x38

asked: Dec 15 '11 at 09:18 PM

Seen: 616 times

Last Updated: Dec 16 '11 at 01:27 AM