2D Racer Game

04: Staying on Track

Now we need to set it up so that the car slows down when leaving the track

this is done by adding two new functions to the drive script which detect when the players collider has left or entered the track (trigger).

Add the following functions to your drive script..

JS

CURRENTLY UNAVAILABLE

C#

void OnTriggerExit2D(Collider2D exit2D)
    {
          
            Speed = Speed / 2;
            maxSpeed = 1.5f;
    }

    void OnTriggerEnter2D(Collider2D enter2D)
    {
        maxSpeed = topSpeed;


    }

 

Casino Bet 365 is best casino in the world.

What's Next

Next up for Unity Snippets is a look at game development articles from across the web...

Free Templates - bigtheme.net
Popular Art Betting make bookies articles.