- Home /
How to make a limited amount of platforms
Hello! I am currently working on a short game for college, and I've been trying for a long time to get some help. My script below is my making platforms script (it spawns platforms wherever I click). My problem is that the player can spawn an infinite amount of platforms, which isn't good as it makes my game too easy (plus it's an easy crash). Like I said, I've been struggling to find any form of help online. Nothing on Unity Answers helps me out, as I feel like my problem is too specific. The answers I got was to spawn platforms in a certain amount of time, which isn't what I want. I tried to ask this question before, but it got rejected for not being descriptive enough. I hope that this is enough to get it approved. TL;DR, I need to make it so the player can only spawn 5 or so platforms per level. If any coding experts can help me out, I'd really appreciate it! I would prefer an answer as soon as possible! Thanks for reading Lewis.
Answer by Envans · Nov 24, 2020 at 01:06 PM
I Will give you some pointers. You should have a variable called maximumPlatforms or something like that and a variable called spawnedPlatforms whenever the palyer spawns a platform increase the spawnedPlatforms count and if spawnedPlatforms >= maximumPlatforms dont allow the player to spawn anymore playtforms. also i would suggest you search on how to add a delay cause it wont be nice if the player can spawn 10 platforms at once.