Smelling is one of the trickiest senses to translate from the real to the virtual world. There are several techniques, but most of them are inclined to the use of colliders or graph logic.
Smelling can be simulated by computing a collision between an agent and odor particles scattered throughout the game level.
As with the other recipes based on colliders, we will need collider components attached to every object that is to be checked, and rigid body components attached to either emitters or receivers.
We will develop the scripts for representing odor particles and agents that are able to smell:
Create the particle's script and define its member variables for computing its lifespan:
using UnityEngine; using System.Collections; public class OdourParticle : MonoBehaviour { public float timespan; private float timer; }
Implement the
Start
function for proper validations:void Start() { if (timespan < 0f)...