It’s final stage of our short delegates and events tutorial. Final stage means we have to defeat giant boss which has huge amounts of HP and devastating weapons. On this occassion we prepared simple Unity game which shows practical usage of delegates. Player (yes, you are now a player 😉 must open it, play it and then understand much as possible to gain new experience and abilities to face reallife difficulties. Let the game begin!
First, watch short game play from our game:
and then play it yourself in your web browser here: AG – simple game
For the best understanding of this post we recommend to:
- get basic informations about creating games in Unity (basic knowledge about colliders, rigidbodies, game objects and user interface elements),
- get some skills in creating C# scripts in Unity to make objects move and interact between each others,
- read our previous posts about LineRenderer and delegates (Aiming with LineRenderer, Delegates #1, Delegates #2, Delegates #3),
- prepare a cup of your favourite drink (programmer is a filter which translates coffeine into code so we recommend good coffee ;),
- turn on your favourite music to have a nice time!
Shortened game instruction
- you have two balls which can be launched and detonated,
- lose as much triangles through blue window as possible,
- change ball mass to see how Unity physics works.
Do you wonder what are these mysterious triangles? It’s the “main character” from our game which can be downloaded from here: New Tap Order. We will be pleased if you play it and beat our high scores!
Places where you can find delegates and events:
- three actions in Aimer which informs about shotting state,
- two events fired by GUIManager to reset the game and changing ball mass,
- Spawner has a destroy delegate to remove all spawned mini triangles from scene,
- there is a new Event Trigger with custom Pointer Click event in AGLogo object,
- Window object has UnityEvent (assigned in Inspector) to inform about collision with triangles.
In this project you can also find some other interesting code snippets like using physics layers, coroutines, delayed functions execution and applying explosive forces to objects. Just check source code. There are many comments for better understanding.
As usual you can download project from here: Download project