Implementing Smell Perception in Unity
Why Smell Matters in GameAI?
In the real world, animals track prey, avoid predators, and find resources using their sense of smell. Implementing a smell perception system can make your game AI feel more natural, intelligent, and alive.
In this guide, I'll walk you through creating a complete smell perception system from scratch—the same system used in my pirate treasure hunting game.
The Core Concept: How Smell Works in Reality
Step 1: Creating the Smell Source
Every Object that emits a smell needs a Smell Source component.
using UnityEngine;
public class SmellSource : MonoBehaviour
{
// Here you can add your smell types
public enum SmellType { Treasure }
// Set a default type
public SmellType smellType = SmellType.Treasure;
// In what radius can the smell be detected
public float smellRange = 50f;
// This calculates how strong the smell is at any position
public float getSmellIntensityAt(Vector3 detector_position)
{
float distance = Vector3.Distance(transform.position, detector_position);
// If too far away, no smell
if (distance > smellRange)
return 0f;
// Smell gets weaker with distance
// Close: 1.0, Far: 0.1
float intensity = 1f / (1f + distance * 0.1f);
return intensity;
}
}Understanding the Math:
I hope it doesn't scare you! Trust me, it's a very simple equation.

That’s all it takes to implement smell decay. Let’s work on the detection part now!
Step 2: Creating the Smell Detector
Now add this function to whatever object you want to give the smell ability.
void checkAllSmells()
{
// Fetches all smell sources in the scene.
SmellSource[] all_smells = FindObjectsOfType<SmellSource>();
// We can multiple smell sources in our game
foreach (SmellSource smell in all_smells)
{
// We calculate the intensity of the smell here
float intensity = smell.getSmellIntensityAt(transform.position);
// Add your logic here
}
}Key Concepts here:
And you are all set! That’s all it takes to implement a very simple smell perception in Unity!
Remember: Every great scent system in games makes the virtual world feel more alive. Whether it's a dog tracking treasure or a witcher hunting monsters, smell perception creates connections between characters and their environments that visual systems alone cannot achieve.
Your game world doesn't just need to look real—it needs to smell real too.