- Home /
Bullets kill enemy... but continue to travel?
Hello, I'm making a simple FPS game and I'm having this problem. What happens is the bullets shoot fine, kill the enemy fine, but keep traveling on after that. They have a Timed object destructor that destroys them in 4 seconds regardless of what happens to them after they spawn, but how can I make it so that if they destroy an enemy, that also destroys the bullet as well, so it doesn't continue to fly for the remaining seconds letting it kill other enemies in that path?
Thanks
Can you post the collision code you use to destroy the enemy and indicate which object the script is attached to (bullet or enemy).
Answer by TimBorquez · Dec 07, 2013 at 03:19 AM
usin the code you posted shouldnt it be like
function OnTriggerEnter (other: Collider) {
if (other.gameObject.CompareTag("Bullet")){
Destroy(other.gameObject);//destroy bullet
Destroy(gameObject);//destroy enemy
}
}
Thanks, worked nicely. Had a feeling it would be something simple. I'll accept your answer.
Just noticed something, this script kills the enemy in one bullet. Is there a way to change this (with this script) so that it takes 3 bullets?
Never $$anonymous$$d, I fixed it! Was very simple.
Your answer
Follow this Question
Related Questions
Bullet not destroying on collision 1 Answer
A node in a childnode? 1 Answer
how to make enemies have health and get damaged by bullets 3 Answers
spraying bullets 3 Answers
Bullet fires before direction change 0 Answers