# Collision causing First Person Controller to go haywire

I have created a first person controller as an enemy in my game (Zombie). My character is an archer that uses arrows as projectiles that are shot with the following code:

if(Input.GetButton("Fire1")) {
shotForce += 45f;
}

if (Input.GetMouseButtonUp(0)) {
Rigidbody shot = Instantiate (projectile, shotPos.position, shotPos.rotation) as Rigidbody;
shot.mass = shotMass;
shotForce = 0f;
}


I have a script to parent the fired arrow to the collided object which works fine for most objects in the game, but my enemy object (Zombie) speeds up and moves all around the place on a collision, I'm new to unity, I've spent a few hours trying to resolve this with out success.

I have a Rigidbody, Charcter controller and First person controller on the Zombie.

I have a Rigidbody and Sphere Collider on the Arrow.

The method I think is causing the problem:

void OnCollisionEnter(Collision collision){
if (this.flying) {
this.flying = false;
Destroy (this.GetComponent<Rigidbody>());
this.transform.position = collision.contacts [0].point;
GameObject anchor = new GameObject ("ARROW_ANCHOR");
anchor.transform.position = this.transform.position;
anchor.transform.rotation = this.transform.rotation;
anchor.transform.parent = collision.transform;
this.anchor = anchor.transform;
}
}


I think the issue is with the line anchor.transform.parent = collision.transform; Maybe there is a solution without parenting the arrow to the Zombie?

I'm stumped at this stage any help appreciated.

• could it be possible that the arrow is adding force to the zombie rigidbody when they collide ? – Uri Popov Apr 26 '16 at 13:39
• I've removed the rigidbody, but it still happens, I think you're on the right track though, something is getting force added to it on the collision, but what and why, I don't know. – JTK Apr 26 '16 at 15:07
• It seems to be the Character Controller that the force is being added to. – JTK Apr 26 '16 at 15:53

I solved this by adding GetComponent<Rigidbody>().isKinematic = true; to my Arrow script in the OnCollisionEnter function.