Physical Representations of a Class (Most likely simpler than it sounds)

Hi, all!

I have a class called Enemy, with just a few variables like HP, movement speed, etc.

I have a script that spawns enemies currently by simply Instantiate()-ing a supplied prefab (for testing purposes). Well, it is all time to tie that together, but now I am slightly confused.

  • How do I make it so that when I spawn a new instance of the Enemy class, it will spawn a physical enemy as well in the constructor that is connected to all of its variables and can be used as a reference to the new instance of that class? I have tried Instantiate, but as the script is just a container for a class, there is no gameObject to instantiate it :confused:

Thanks!- YA

Hi YA,
There is a number of scripts here on unity answers for enemy spawning, This one may be of use to you:

We also cover spawning objects/enemies several times in our tower defense series.
http://cgcookie.com/unity/2012/06/04/unity-tower-defense-tutorial-part-02-sam-turret/

I hope this helps!