Lesson 5: Counter

Counter.cs

Create a new script called “Counter,” and then add the code below. Attach this to your Game Engine gameObject.

Wire up the Simple Counter

The video below doesn’t precisely demonstrate how to wire up this counting mechanic, but it will show you general settings for UI elements.

Collision.cs

To create a more complicated, but perhaps more accurate counter, use the code below. Note, you will have to use Unity’s “Tag” feature to make the code work.

Attach the script below to your ninja prefab:

CollisionCounter.cs

Attach the script below to your GameEngine:

Project Files

If you cannot troubleshoot your way past any problems. The link below provides a download to the project files up to this point: