- Home /
Question by
amichael · Oct 15, 2017 at 03:13 AM ·
randomspawning
How would i get a prefab to pop up randomly? C#
Im messing around with a game and i want a prefab to pop up (like a wall) and then disappear randomly. If character has to try and time it correctly or he will hit the wall. Im not sure how to pull this off.
Comment
Answer by Cynikal · Oct 15, 2017 at 04:23 AM
In short, what you could do is something along the lines of like (psuedo code)
Start a Coroutine, Get a random.range between two values. call for it to disappear(the item), Yield Return New WaitForSeconds(YourRandomedTimer), call for it to reappear. Recall the same coroutine.
Fairly simple process, so I didn't feel the need to code it, but if you have any questions, feel free to ask.
Your answer
![](https://koobas.hobune.stream/wayback/20220612141052im_/https://answers.unity.com/themes/thub/images/avi.jpg)