- Home /
Shoot Bullet Delay Enemy
So i got this script here in unity answers
// EnemyTargetArea script:
var waypoint : Transform[];
var bullitPrefab:Transform;
private var currentWaypoint : int;
var speed : int = 0;
var followrange : int;
var stoprange : int;
static var canmove : boolean = true;
var target : Transform;
private var stopped : boolean = false;
function Update(){
if(Vector3.Distance(target.position, transform.position) <= followrange && stopped == false)
{
animation.Play("GolemWalk");
canmove = false;
transform.LookAt(target);
transform.Translate(Vector3(0,0,1) speed Time.deltaTime);
}
if(Vector3.Distance(target.position, transform.position) <= stoprange)
{
animation.Play("GolemAttack");
canmove = false;
var bullit = Instantiate (bullitPrefab ,transform.Find("RockSpawn").transform.position , Quaternion.identity);
bullit.gameObject.tag = "fallout";
bullit.rigidbody.AddForce(transform.forward * 700);
transform.LookAt(target);
stopped = true;
}
if(Vector3.Distance(target.position, transform.position) > stoprange)
{
stopped = false;
}
if(Vector3.Distance(target.position, transform.position) > followrange)
{
animation.Play("GolemIdle");
canmove = true;
}
}
( i used the bullit from tornado twins) My problem is my bullitPrefab is spawning massively when the enemy reach the player
the enemy is shooting tons of bullit,
anyone can help here how do i Delay the bullit spawn? ( i already tried yield WaitForSeconds(1); but im getting update() cannot be a coroutine) thanks in advance :D
edit: i have looked everywhere here in unity answer but i find it hard putting the script in my script
Your answer
Follow this Question
Related Questions
Problem with enemy shooting 4 Answers
Bullets don't always appear at spawn point 0 Answers
No collision on trigger and character controller 1 Answer
Hit enemy life 0 Answers
Enemy Instantiating one bullet 3 Answers