D
D
DennisDen2018-06-29 14:41:32
Unity
DennisDen, 2018-06-29 14:41:32

[Unity] How to spawn objects?

My spawn has a link to the enemy prefab. The enemy itself is present on the scene (let's call it Parent). When starting the game, the enemy flies towards the target and is destroyed on impact. Spawn creates clones of enemy as long as the Parent exists on the scene. If the Parent collided with the target, then the spawn loses the reference to the prefab and clones are no longer created. How can this problem be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-06-29
@DennisDen

It should be:
1. A link to the prefab GameObject enemyPrefab
2. We create any Enemy from a prefab, even the first one.Enemy enemy = Instantiate(enemyPrefab)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question