- Home /
Question by
Reaper_actual · Aug 11, 2014 at 02:47 AM ·
enemyrespawn
Enemy respawning after death
I have a basic enemy AI set up in my open world game, and i was looking at scripts that respawn the enemy, and short term they seem to work well but the enemies just chase you until youre far enough away, which means you could just get all the enemies in a town and bring them into the sea and get far enough away so they would leave you alone, so my question is, is there any way to respawn an enemy after a while after it dies, but also after a time when you are far enough away from it?
Comment
Answer by Reeceg · Aug 11, 2014 at 04:26 AM
var distanceTillRespawn : float;
var LookAtTarget : Transform;
function Shoot(){
var distance = Vector3.Distance(LookAtTarget.transform.position, transform.position);
if (distance >= distanceTillRespawn){
//your respawn function
}
}
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
enemy spawning when dead 1 Answer
keeping the xp after death 2 Answers