|
The game i am working on is about spawning ramps in front of cars. i have a simple spawning script that works fine. but i want to restrict the amount of clones i can make, was wondering how. THanks.
(comments are locked)
|
|
This how I recently solved this problem: Where the var 'MaxObjectCount' adds one each time my Prefab spawns in the Update function, and in my 'checkhit' function I set it to destroy the first one I spawned after a set limit. So I can only have 15 clones at a time. I'm fairly new and don't know if this is the best approach, but it works. I am now working on allowing the MaxObjectCount var to speak to the prefab so I can also keep track of the info to be able to do the same when I destroy my prefab via a collision. I hope this helped.
(comments are locked)
|

This completely depends on your script really. Without knowing anything about it all I can say is that you'll have to keep track of the number of ramps you spawned and when you're about to place a new ramp you check if you've spawned more ramps than is allowed.