How do I randomly generate two obstacles in a 3D endless runner with 1 gap to go through?
Hey im new to unity 3D and im in the middle of creating an endless runner. ive currently got the game running with a player constantly going forward and the user can move the player left or right, whilst the game generates the level constantly.
Now i want the game to also generate walls as obstacles with a gap to go through, but randomly. I also want it to score 1 point once the player has gone through the gap?
Ill be very grateful to anyone who is willing to help me! Ive placed a screen shot at the bottom to give an idea of where im at.
Thank you in advance :)
Answer by hexagonius · Sep 19, 2015 at 09:00 PM
I'd runa coroutine forever (while true) with a yield for seconds and an instantiate. I'd instantiate a prefab consisting of a gameobject under which the two wall segments are placed apart from each other and their bottoms aligned with the parent position y. when instantiating, generate the position vector and use player z plus a front offset, track x plus random offset but max half track width minus half width of total prefab width and half track y.
Right okay thank you very much, Ive got one problem... I dont know how to put that into a code format! could you help guide me through it? sorry its a big ask i know! @hexagonius