To make everyone a winner

I decided that my version of project boost should just count how many times you hit the wall as your score and the lower the score the better. Does this seem like a good idea. Here is the first level I made following the tutorial. I am unsure how to implement my mechanic but I guess I will try after watching the rest of the videos and following along.

2 Likes

sounds like a good idea. would imagine you make a public static int to store the value, and update it in in the Switch part of the code.
i dont remeber if this is the best way atm, but testet it in my code and i get the score updatet when i collide with walls, ground etc.

something like this:



public static int score;

private void Start()
{
}

    // Update is called once per frame
    void Update ()
    {
    }

private void OnCollisionEnter(Collision collision)
{
        switch (collision.gameObject.tag)
        {
            case "Friendly":
                Debug.Log("OK");
                break;               
            case "Fuel":
                Debug.Log ("Fuel");
                break;
            default:
                score += 1 // adds +1 (Set the value you want) to the score when hitting ground or wall
                break;
        }
}
1 Like

@SatireOfComedy Let me know how it works out :slight_smile: sounds like a nice touch

Privacy & Terms