- Home /
Player and enemy collision
I have currently have an EnemyCollider script attached to the enemies that looks like so:
function OnTriggerEnter (other : Collider) {
switch(other.tag){
case("PlayerBullet"):
Destroy(gameObject);
break;
case("Player")
Destroy(other.gameObject);
break;
}
}
When a bullet collides with the enemy all is good. But I can't get it to work on the player object. Both the enemy and the player have a rigidbody component the enemy has a capsule collider with isTrigger set to true.
Where could be the problem?
Try putting the code to process the player case in an OnCollisionEnter().
Answer by Alex808 · Mar 07, 2013 at 03:23 AM
I found part of the problem the collision is actualy never happening... I am using transform.LookAt and it has a weird behavior once the enemy is close to the player....
Your answer
Follow this Question
Related Questions
Can I make Ai using only a focus script and a bullet script? 1 Answer
Enemy not taking damage on collisions. 2 Answers
Collision Detection Issue with SetActive(false) not working 2 Answers
No player is colliding with enemy even with capsule collider !!! Please me help me. 0 Answers
Taking damage from an enemy on collision 2 Answers