Lab2 : First Unity game, roll-a-ball

Disclaimer : Labs and Lectures concern the course Human Computer Interface which I follow with my M2 "Virtual and Augmented Reality" at IPParis.

Goal

Roll-a-boll is a simple game : you are a ball (purple) and try to catch all of collectibles (cyan). Your score is on the top left and with an amount of it you will earn the message "You Win !". You have the Unity tutorial on this link, these are videos that detail each step.


Our creation

 First step is to create a unity 3D project, let's call it Roll-a-ball. Then I build the scene : a set with wall and our future player in the middle.


We know need a script to make our game playable, don't forget to add "Player Input" to our player. You can see bellow the script (all is available on my github).

Our ball is now moving, we can focus ourself on the camera , we want our camera to follow the player:

It's time to add our collectibles I decide to write TSP and INT which are acronym of my school. I also add a little script to them "transform.Rotate(new Vector3(0, 90, 90) * Time.deltaTime);"  in update function to make them rotate.

I complete PlayerController with an OnTriggerEnter() function, to make Collectibles dissapeared when player touch it. Tag is important otherwise without if-condition other objects could disappear.

Last thing is to add an UI (User Interface) to display score and an end message. You could check on PlayerController how it works in detail using TMPRO library. Just check what appeared in PlayerController, all functionalities without UI are above.

Now our game is finished we can build it. Go to Files > Build Settings. Select the scenes “Scenes/roll-a-ball” then open Player Settings. Here we make this game windowed (it’s better for a game without menu).

Roll-a-ball.exe can be played on every PC, Mac & Linux Platform, you can try it on my github (version for mobile too).