Throws once every 5 seconds
This commit is contained in:
@@ -12,6 +12,8 @@ public class ThrowerEnemy : MonoBehaviour
|
||||
|
||||
public float playerDistance;
|
||||
public GameObject GunThrow;
|
||||
public bool canThrow = false;
|
||||
public float throwTimer = 5;
|
||||
|
||||
private NavMeshAgent agent;
|
||||
public Transform target;
|
||||
@@ -35,14 +37,24 @@ public class ThrowerEnemy : MonoBehaviour
|
||||
if (!isInside && hp != 0)
|
||||
MeshRenderer.material = def;
|
||||
|
||||
if (!canThrow)
|
||||
{
|
||||
throwTimer -= Time.deltaTime;
|
||||
|
||||
if (throwTimer < 0)
|
||||
{
|
||||
canThrow = true;
|
||||
throwTimer = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
playerDistance = Vector3.Distance(transform.position, target.position);
|
||||
if (playerDistance < 25)
|
||||
if (playerDistance < 25 && canThrow)
|
||||
{
|
||||
Instantiate(GunThrow, transform);
|
||||
canThrow = false;
|
||||
}
|
||||
}
|
||||
private void LateUpdate()
|
||||
|
||||
Reference in New Issue
Block a user