- Home /
Platform Falling when player collides
I am trying to make it so that when the player collides with the platform it activates the gravity on a rigidbody causing the platform to fall out from under him, but it's the player who falls through the platform. here's my code... function OnTriggerEnter (other : Collider) { if (other.attachedRigidbody) { other.attachedRigidbody.useGravity = false; } } collider.isTrigger = true;
what am I doing wrong? please help
Comment
Seems like you attached the script to the player. so when the player collides with the platform he falls because he's the one who's gravity is altered not the platform. Try this: Attach something like this to the platform:
static var isTouched : boolean;
function Start(){
isTouched = false;
}
function isTouching(){
if(isTouched == true){
/*alter the platform gravity sorry I don't know how to do that
via code*/
}
And this to the player character:
function OnTriggerEnter(other : Collider){
if(other.attachedRigidbody){
isTouched = true;
}
}