OncollisionEnter Help!!

Hello guys i am in need of your help yet again :).

Here is my problem:

I have an axe and a tree. The player which is an FPC controller first picks up the axe(and thus the axe becomes the child of FPC in the heirarchy) and it works just fine. the code is as follows:

static var axeOn : boolean = false;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
		if(hit.gameObject.tag == "tree")
		{
			
				
		}
		
		if(hit.gameObject.tag == "axe")
		
		{
		
			if(axeOn == false)
			{
			
			
			axeOn = true;
			hit.gameObject.transform.parent = transform;
			hit.transform.localPosition.x = 1.027371;
			hit.transform.localPosition.y = 0.2108669;
			hit.transform.localPosition.z = 0.1075801;
			hit.transform.localRotation.x = 0;
			hit.transform.localRotation.y = 180;
			hit.transform.localRotation.z = 0;
			
			}
			
			
			
		}


}

Okay the problem is here when i want to detect the collision between my axe and the tree. They both have a capsule collider in which i fixed properly but in the script they are not really colliding and thus nothing happens. Here is my script :

function OnCollisionEnter(theObject : Collision)
{

		if(theObject.gameObject.name == "tree")
		{
			
			animation.Play("TreeAnimation);
			
		}

}

but the collision is not occurring and nothing is happening could you tell me what my problem is.

thanks for your help
the

Add a rigidbody to your axe ? (remember to set Use gravity off)

i did that but now the axe is not following me as in its staying only in one position only rotating do u have any idea?

Hmm, put it to IsKinematic On, to see ? But in this case, you will have to use OnTriggerEnter instead of OnCollisionEnter.

IsKinematic works but i did use onTriggerEnter but now i cant pick up the axe?

function OnTriggerEnter(theObject : Collider)
{

		if(theObject.gameObject.tag == "tree")
		{
			
			Destroy(gameObject);
			
		}




}

although i tried to move the axe in the scene view and the collision works but now how to be able to pick up the axe hmm…

You must use OnTriggerEnter too to trigger the fact you touch the axe.

I just hope it works with a CharacterController (if that’s what you’re using).

yep it works really appreciate ur help:) thanks a lot