We were learning about C# classes and basics of Unity. Inside a Scripts folder, we made different files for each class. We named each class after it’s type.

One of my classes was for spawning animals every second. In Unity, I created a flat square and applied a simple grass texture on it. I found a free texture on the Unity website. I also found an animal pack there. I imported them to my project files in Unity engine. From animal pack, I decided to use a cat as the animal I want to spawn.

The code below shows how the SpawnAnimal is executed.

The screenshot shows the grass texture already applied to the flat surface. When I press “play” (middle top), the code start execute.

One cat is spawned per frame. There’s a bunch of cats already spawned. It happens infinitly untill I stop the code from further execution.

Leave a Reply