- Home /
Question by
BobbleHead · Dec 15, 2011 at 09:18 PM ·
gravityontrigger
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!
Comment
Answer by Lo0NuhtiK · Dec 16, 2011 at 01:27 AM
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"
Your answer
![](https://koobas.hobune.stream/wayback/20220613062123im_/https://answers.unity.com/themes/thub/images/avi.jpg)