Created
January 13, 2026 15:51
-
-
Save JaiParakh/09006c03894f1ccd4ce2cf5698564e10 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment