using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;
public class enemyInst : MonoBehaviour
{
float time;
public GameObject EnemyObj;
GameObject PlayerObj;
private float _radius = 10;
void Start()
{
PlayerObj = GameObject.Find("Player");
}
void Update()
{
time += Time.deltaTime;
if (time >= 1) {
time = 0;
GameObject obj = Instantiate(EnemyObj);
Vector3 childPostion = transform.position;
float angle = Random.Range( 0, 360) * Mathf.Deg2Rad;
childPostion.x += _radius * Mathf.Cos(angle);
childPostion.y = transform.position.y;
childPostion.z += _radius * Mathf.Sin(angle);
obj.transform.position = childPostion;
obj.transform.LookAt(PlayerObj.transform);
Rigidbody rb = obj.GetComponent<Rigidbody>();
rb.AddForce(obj.transform.forward * 5.0f, ForceMode.Impulse);
}
}
}