Collecting Coins

Jack Leavey
Oct 17, 2022

--

With the movement system implemented, it’s time to actually collect the various coins spread across the level.

First, I add a Canvas with a Text element for the UI.

I also make 2 new C# scripts; UIManager for the Canvas, and a Coin script for the Coins themselves.

Both of these scripts are very simple;

Coin:

This script checks for a collision, then calls logic on the Player and destroys itself.

UIManager:

The Playercontroller calls this function which updates the coin counter UI.

Finally, a new function is added to the playercontroller:

We send the current coin count on the player as an integer variable to the UI manager.

Let’s see it in action!

--

--

Jack Leavey
Jack Leavey

Written by Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!

No responses yet