Roller Ball Update Timer & Elevators

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
TimeTextfont and colour I then had to go to the PlayerController timegameviewshotscript 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.

timerscriptThe 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.

Level in Progress box is checked and Level Duration Time is being tracked as level is being played.
Time displayed in the centre left of game screen.

After changing around Level 1 and adding my designer touch, I ended up with….

Scene 1 Unity Editor Scene screen shot.
Level 1 Game View

Level 2
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.
Level2_vertical_section.PNGTo 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’.
Elevator_scriptThe 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.
elevators_working_scene_viewWas 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.
elevator_game_view 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.
So I…

Adding two new public int, enabled me to set the minimum and maximum heights in the inspector for each platform. No more multiple scripts! Another Eureeka moment and guess whats its 12.46am!!

God’s blessings upon you.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s