Tuesday, 6 October 2020

Activity 4: Simple Score Counter


                Creating this Simple Score Counter is a bit complicated for beginners like me because it tackles new components in Unity, specifically, the UI Component where I can use different features like canvas, positioning, and animating, defining user interaction, and sizing layouts automatically. 

Components are functionality we can provide to our game objects, Specifically, a Camera Component, a GUILayer, a Flare Layer, and an Audio Listener.

 I also used Scripts in order to read input from our game objects it interacts. It also provides the physical behavior of objects like moving an object using a keyboard or mouse.

    First, We need to import our game objects to our assets which I created using Adobe Illustrator. Here I have the red ball, coins, bombs, and frame. 



        
        Then I created a Text component from UI where I clicked it on the hierarchy Tab. It will create a canvas with a child called Text.



     It is relatively large over the Main Camera but we will not move it together to the size of the main camera. Let's move the text box in the middle and change the text to "Score" from the inspector tab. Then I created a script for Score Text, this will now display our scores from the game.

            

Score Script

Next, I drag down all game objects from assets into the Scene. Just like the previous activity, the ball movement, coin, and moving bomb have the same behavior. But the difference is whenever we collide the red ball to the coin it will record a score, while when we hit the moving bomb it will decrease the score.  


                                                         Game Scene


    


Additionally, I made another script for the ball so that it will sense the coins and bomb whenever they touch. The name of the game objects must be the same inside our switch cases so they will recognize each case. Now the Destroy() method hides the object when it triggers a collision.

    
    Here are the characteristics of my coins and bomb.                        
                
                                                                       Coin Characteristic


Bomb Characteristic



                                                                Now my final output



No comments:

Post a Comment

Activity 8: Game Level Feature

              This blog contains information about next level features using Unity 2D.  First, We need Following Image Objects : Player, Met...