The story: In this game you are as a player who is stuck in a forest and to run away from there you should collect some objects in the forest and give them to a box called Mr. Box.
Different parts of the game:
 - In order to play the game, you have two options. You can play the game by pressing the Play button on the main menu to play on a pre setup forest, or you can press Level Editor button and design your forest as you wish and then play on that.
 - On the Level Editor section, you can change the tree coverage area and the forest ground by editing the length and the width. The tree coverage area and the forest ground can be changed separately. You can also change the density of the forest and the number of objects that you should collect on the game.
The challenges of the game
 - The trees and the location of trees and objects to collect on the game will regenerate every time you play or reset the game, so you will face a new environment each time you try the game.
 - You can collect objects only when you look straight at them while you should always look at the scarecrow (the guard of the forest). So, you should either manage to look at both of them at the same time when you are collecting or collect the object really fast to look back at the scarecrow again.
The mechanic of the game
 - Objects to collect are placed on the trees of the forest and you can collect them by pressing E on your keyboard when you are close enough to them and looking straight at them.
 - In the game you should always try to look at the scarecrow (the guard of the forest) otherwise it will run toward you and if it gets close enough to you it will hunt you and you will lose the game.
 - In order to win the game, you should collect all the objects in the forest and give them to a cyan color box called Mr. Box.
The Algorithms and techniques that I used
- To generate trees in the game I used Poisson Disc sampling technique. Without it every tree in the game should have checked the distance between itself and all other trees to place them at a specific distance from each other. But now it uses a grid system, and each tree is placed on a block of this grid and each block just checks the distance between itself and blocks around it. It really optimizes the game specially in the Level Editor section that trees will be generated every time that you edit the map.
 - To find that the player is looking at an object and/or scarecrow, I used just a simple vector math, dot product. And for scarecrow rotation I used a little bit of trigonometry to find the angle. I also used cross product to specify the way of rotation (left or right). I believe I could just use LookAt function inside unity engine for rotation, but I wanted to practice my math as well.
Device Support
The game build is WebGL and runs on web browser.
Click here to play the game.
Unity packages
Polygon Trees by Alebrijes Studio.
Unity Cinemachine package.
Resources
In this game i used Poisson disc sampling technique to generator the level, so every time you reset the game the map will change.Thanks Sebastian Lague and The Coding Train for describing the technique:
All the Rotation and Look direction in this game are made by pure math.
Thanks Freya Holmér for a great free course on math for game development.
Back to Top