Answer the question
In order to leave comments, you need to log in
Why doesn't placing prefab instances with a script work?
There is an Enemy prefab, its instances are created by an empty object with the following component:
using UnityEngine;
public class Spawn : MonoBehaviour {
[SerializeField] private GameObject EnemyPrefab; //need to be initialized in editor
private GameObject spawned_enemy = null;
void Update () {
if (spawned_enemy == null) {
spawned_enemy = (GameObject)Instantiate (EnemyPrefab);
spawned_enemy.transform.position = this.transform.position;
spawned_enemy.transform.Rotate(0, Random.Range(-90, 90), 0);
}
}
}
Answer the question
In order to leave comments, you need to log in
Try to watch this video
It seems that you are setting Instantiate incorrectly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question