- Home /
Falling object pauses before colliding
Hey, I'm trying to program a falling obstacle for a 3D platformer, here's my code:
var obstacle : Rigidbody;
var falling : boolean;
function Start(){
falling = false;
}
function Update(){
if(falling == true){
obstacle.useGravity = true;
obstacle.isKinematic = false;
} else {
obstacle.useGravity = false;
obstacle.isKinematic = true;
}
}
function OnTriggerEnter(col : Collider){
if(col.gameObject.tag == "Player"){
falling = true;
}
}
The code works fine, the issue I'm running into is that the obstacle pauses before it actually collides with the player, which is causing issues with running code to kill the player. To be more exact, the obstacle pauses, and then continues to fall again until the collider actually strikes another object. Can anyone shed some insight into this issue?
Do you have a lot of code in FIxedUpdate(), in other scripts and have you altered the Time $$anonymous$$anager settings?
Perhaps find another way to perform the code in your update, incase Spam$$anonymous$$g the rigidbodys gravity flag is causing your problem. Perhaps place them in a function.
I haven't messed with the time at all, is there something I should be looking for in particular?
I just tried moving the code outside of the Update at your suggestion, still having the same issue...
I only have one script that is running a FixedUpdate(). It's attached to my camera and it's only running 5-6 lines at most.
To clarify further, the object falls when I enter the trigger. But it almost reacts as if there is another collider attached to the object that is larger than the object. It falls, pauses, then falls again.
It seems to only do it to the character controller too. When I place a cube under the object with a rigidbody and box collider attached, I do not get the same result.
Your answer
![](https://koobas.hobune.stream/wayback/20220613152649im_/https://answers.unity.com/themes/thub/images/avi.jpg)