As promised, I have figured out some more additions to my Roller Ball version.
I managed to add a timer to the game screen. First I created new UI text in the hierarchy and renamed it Time Text. After moving it to the position I liked as well as changing the
font and colour I then had to go to the PlayerController script and create some new variables:
private integers ‘secondscount’ and ‘minutecount’.
public float ‘levelDurationTimer’.
public bool ‘LevelinProgress’.
The public bool will be used later when I hopefully create a level manager. This will instruct the timer to reset when the next level starts.
The code tells the game to start the timer when the level is in progress. I also tells the UI text to update the timer as it is functioning.
After changing around Level 1 and adding my designer touch, I ended up with….
For Level 2 I wanted to mix it up a bit and apply some other features and mechanics. I wanted to implement a section of the game where the player has to direct the ball up a wall.
To do this I simply duplicated the Playing Field and moved and flipped it so that it sat along the back or north edge of the horizontal playing field.
I added some ramps and imported a photo to make a new material but I was stumped as to how to get the ball higher without just using ramps or spinning objects. So he idea of elevator platforms was born.
To make the elevators work I created a platform and once again imported a picture to make my own material. I then had create and add a new script to the elevator platform called ‘Elevator’.
The lines 14 and 18 determine how high the elevator ascends before descending to the lowest position as assigned in the code.
Lines 16 and 20 tell the platform which direction to go when that level is reached.
Was quite happy with myself working that one out. It was another Eureka and yahoo moment that always occurs in the late hours of the night after hours and hours of mental effort.
I wanted to make a third level but time does not permit and I have pretty much pushed this tutorial to where I want it and what I could do with it.
I still have to add some menus to start the game as well as end the game. If I have time, and I really would like to see this implemented, is a leader board where your best time for each level is stored.
Till next time, thank you for your company.
I was building a third level and wanted elevator platforms as well but didn’t want to have to make multiple scripts, one for each elevator platform, setting each minimum and maximum height.
God’s blessings upon you.