Help with isKinematic

hello, I have a game object that is set to isKinematic when it starts. I want it to turn off isKinematic when it collides with a specific object. then ture isKinematic back on. Here is my code. . .

function OnCollisionEnter(collision : Collision) 
{ 
      if (collision.gameObject.tag == "BreakAway") 
      { 
         if (rigidbody.isKinematic == true)
		 { 
		 rigidbody.isKinematic = false;
		 }
		 if(rigidbody.isKinematic == false)
		 {
		 Destroy (collision.gameObject);
		 }
      } 
    }

I dont understand why my object is not turning of isKinematic. I kind of have an idea of how to turn it back on using OnCollisionExit. but first I have to turn off the isKinematic. any help would be great.

I’m a bit confused… why would you want to turn off iskinematic if all you want to do is turn it back on?

good question :smile:

I actually changed some things around and now I dont kneed it to turn back on. Still the problem continues where I can turn it on to start but not turn it off on collision.

Lets see if I can describe what I need a little better.

I have my character that jumps into a wall. the wall rotates and when isKinematic is off the wall shifts and moves just during gameplay. So i have it starting isKinematic. When my character collides them if they are Kinematic they wont Destroy(gameObject) so I am trying to have in the middle of the collision to first set isKinematic to false, then Destroy(gameObject) for some reason its not turning isKinematic off to let them be destroyed.

I am just very confused, very ver confused.

Update…

here is the code I am using on the walls

rigidbody.isKinematic = true;
function OnCollisionEnter(collision : Collision) { 
		rigidbody.isKinematic = false;
       
      if (collision.gameObject.tag == "BreakAway") 
      { 
         //rigidbody.isKinematic = false;
		 if(rigidbody.isKinematic == false)
			{
			Destroy (gameObject);
			}		
      } 

}

So… that code is on the walls?

And you have your player tagged as BreakAway?

yep, and yep

So… what happens when the player hits the object? have you added some debugs or print calls to make sure it’s processing thru the code?

it seems like the whole purpose of this code is to simply destory this wall object the player is hitting. Simply calling destory on it should do the trick.