Critter Kart: Procedural Generation Kart Racing Experience
A kart-racing "casino" game where the scene is procedurally generated and karts&creatures are moved by AI. The procedural techniques include Unity Spline, superposed Perlin Noise, Fast Fourier Transform Noise. AI objects are moved on Behavior Trees.
Discover the different traits of your karts and enjoy the environment!
Don't worry! There is no need to control the kart! Just watch, fly and guess, as the creator of this land. Will the kart you choose win the race? 🤔
Game Website: https://eisto123.itch.io/critter-kart
🌟 Credit
Zemeng Li
-
Path & Fence generation
-
AI cars with 9 traits
-
Racing game features
-
UI - Car Traits choose & Ranking Board & Ending page
Peiheng Cai
-
Terrains generation & objects placements
-
Shaders
-
AI rabbit
-
UI - Start page & Player control
Features
A toon style forest envitonmment generated procedurally


4 AI karts with different traites racing on the path


A few AI rabbits in the scene, walking, drinking and eating.


My Contribution

Terrain Generation & Object Placement
Terrain Generation
Basic Steps: Set the terrain size and height map resolution-> For each height map point, create a noise-> For each height mappoint,normalize thenoise into [0,1]
Perlin Noise: Perlin Noise can generate terrain with rich details and is easy to customize the parameters. Since the closed racing path is hard to set along the terrain, the terrain needs to be relatively plain, or the car can never move to the hill top
FFT Noise: Fast Fourier Transform generation is used for the terrains around. Use this method instead of Perlin Noise is because this can make mountains sharpe rand more suited for land scape.The terrain will have more up and down changes as well.


Object Placement
Basic Steps: Generate humidity map & temperature map->Generate biome map->Place trees->Place g Grass-> Place plants-> place underwater rocks & plants-> Place food for rabbits
Humidity map & Temperature map: The humidity and temperature at each point of the terrain is calculated by the point height andPerlin Noise, which is generated with the Perlin Noise class used for terrain generation.
Generate Biome Map:
The biome for each point is based on the temperature and humidity.
Each biome type information is stored by acustomized config file, where prefabs, densities, colors can be set in advance.

AI Rabbits
The AI of rabbits use both State Machine and Behavior Tree. The state machine is to differentiate behaviors from drinking, eating and moving. And Behavior Tree controls the state change and some complex decisions to choose target positions. Pathfinding from the current position to target position is done by NavMesh.
State Machine
AI rabbits have four states: Drink, Eat, Heal, Idle, stored in enum RabbitStatus and also some methods which can be called by Behavior Tree. In the Behavior Tree, the tree will call methods in Rabbit to move and change status.
valueThirsty and valueHungry represent how thirsty and hungry the rabbit is. If these two values are under thresholds, then the rabbit needs to find water/food to recover the values. Drink, Eat, Heal methods are quite same. They use a timer to control the state time and recover values. But each time the values recover relatively random points. Move is done by setting the NavMesh target.







Behavior Tree
The behavior tree will change the rabbit status and conduct some decisions when rabbit is moving. If the rabbit doesn't need to drink/eat right now, the rabbit will follow random target to follow. The random target will change when the rabbit arrives the previous one.
If the rabbit needs to drink/eat, then it will search in a sphere. Find one, set this to the next target. It is worth mentioning that when valueThirsty or valueHungry drops below the threshold, the rabbit will prioritize searching for the colorful carrot. This item acts like a magical potion — once eaten, it instantly restores the rabbit to full health. Therefore, when the rabbit is in a thirsty or hungry state, it will first seek out this "magical potion." Only if it cannot find one will it then search for water or normal food.
If rabbit doesn't find any expected object, then it still follows the random target. Finally, check if the rabbis arrive at target water/food, to see whether the status needs to change.


Shader
Terrain
According to the pixel height, decide if this pixel is in sand or grass. Basically lerp the color and normal map between sand to grass. If this pixel belongs to path, add the path texture.


Grass
Base Color:
a) Lerp color between near color and far color based on the distance to player.
b) Lerp color between bottom to high, to let the bottom color closer to the terrain color.
c) Receive shadows and lerp color to the shadow color according to the shadow strength.
Vertex Displacement:
a) Wind Move: if not detect player approaching, use wind noise to randomly move the grass at x-z axis. And lerp the displacement value from bottom(lowest) to top(hightest)
b) Player Detect: Calculate the ratio between distance from player to the pixel, and the search radius, to decide the move strength. Move direction is based on $$pixelPos-playerPos$$. Displacement vector will follow the equation if player is inside the detect circle





Water
a) Shallow and deep area: Lerp the color between Shallow area and Deep area based on the depth
b) Foam: Use depth distance to detect edge and realize the effect of edge foam. Randomly move the foam using gradient noise and lerp the color from water itself to foam color
c) Refraction: Use time offset and gradient noise, create normal noise under the water, and use the disturbance of the water surface normal to distort the screen UV.
d) Wave Vertex Displacement: Change the y position of water pixel





