- Home /
Kinematic rigidbody only triggering once
I have an object with a bunch of rigidbodies and colliders as its children. I have a static trigger in my scene, this gets triggered by the rigidbodies.
But at some point I turn all the rigidbodies to kinematic and turn of all colliders except one. That collider triggers the trigger once, but after that it will not trigger any more until I turn of kinematic again.
I tried to add a rigidbody to the trigger, but still the same effect.
How to fix this?
EDIT:
Just found out the OnTriggerStay keeps getting called after the first time it enters the trigger, even when the colliders are clearly not colliding anymore.
Have you tried using OnTriggerExit
to tell the objects in game when they have left it? If that doesn't work then you could try turning the kinematic on and off through the script by saying that if collision is true then do some logic and then set it to false again after the logic has been carried out.
The exit never gets called, but the rigidbody must be kinematic at that point, I may not turn it off.
Well from what I know if you don't tell the trigger when the player has left it then it simply assumes it's always in it and will not trigger again if you try to enter it again.
$$anonymous$$aybe you could tag your collider and then in the script that controls your player and have something like this :
var hitTheTrigger = false;
function OnTriggerEnter(object : Collider)
{
if(object.gameObject.tag =="Name of the tag")
{
hitTheTrigger = true;
//logic here
}
}
function OnTriggerExit(object : Collider)
{
hitTheTrigger = false;
}
That wouldn't solve the problem because the OnTriggerExit is not called. And I don't have to tell the trigger a collider has exited. The Physics engine should do that.
Then honestly I have no clue how to help you out. This is how I generaly go about doing things and I don't like relying on the physics engine to do anything except for actual physics.
Your answer
Follow this Question
Related Questions
Collision between two kinematic rigidbody triggers 2 Answers
How to add a Kinematic Rigidbody to a cube? 1 Answer
CPU cost of using multiple rigidbodies 0 Answers
Rigidbody triggers are pushing a CharacterController.. 3 Answers
Kinematic Rigidbody Collider not colliding with Static Trigger Collider 3 Answers