Я создал объект "враг" на него поместил скрипт.
- Код: Выделить всё
public GameObject objectsEnemy;
Синтаксис:
Используется csharp
public class EnemyLogic : MonoBehaviour {
public GameObject objectsEnemy;
GameObject bullet;
// Use this for initialization
void Start()
{
Vector3 pos = transform.position;
Debug.Log(pos.x + " " + pos.y + " " + pos.z);
var objectsEnemys = objectsEnemy.GetComponent<BulletLogic>();
objectsEnemys.setPositionsVector3(pos.x, pos.y, pos.z);
Instantiate(objectsEnemy);
}
// Update is called once per frameЫ
void Update()
{
// Destroy(GameObject.Find("bullet(Clone)"));
if (GameObject.Find("Bullet(Clone)") == null)
{
Instantiate(objectsEnemy);
}
}
}
public GameObject objectsEnemy;
GameObject bullet;
// Use this for initialization
void Start()
{
Vector3 pos = transform.position;
Debug.Log(pos.x + " " + pos.y + " " + pos.z);
var objectsEnemys = objectsEnemy.GetComponent<BulletLogic>();
objectsEnemys.setPositionsVector3(pos.x, pos.y, pos.z);
Instantiate(objectsEnemy);
}
// Update is called once per frameЫ
void Update()
{
// Destroy(GameObject.Find("bullet(Clone)"));
if (GameObject.Find("Bullet(Clone)") == null)
{
Instantiate(objectsEnemy);
}
}
}
Но когда я клонирую врагов
Синтаксис:
Используется csharp
void Start()
{
for (int i = 0; i < 5; i++)
{
GameObject instance =
Instantiate(enemy, new Vector3(5f+i, -i+3f, -.3f), Quaternion.identity) as GameObject;
}
}
{
for (int i = 0; i < 5; i++)
{
GameObject instance =
Instantiate(enemy, new Vector3(5f+i, -i+3f, -.3f), Quaternion.identity) as GameObject;
}
}
Последний враг только стреляет, хотя перед запуском сцены каждый враг единожды выпустил пулю.