23 lines
700 B
C#
23 lines
700 B
C#
using UnityEngine;
|
|
|
|
namespace CreatureControl {
|
|
|
|
public class Odorant : MonoBehaviour {
|
|
public float strength = 1;
|
|
|
|
public float StrengthAt(float distance) {
|
|
if (distance <= 0)
|
|
return this.strength;
|
|
|
|
float intensity = this.strength / (4.0f * Mathf.PI * distance * distance);
|
|
return intensity;
|
|
}
|
|
public Vector3 StrengthAt(Vector3 localPosition) {
|
|
float magnitude = localPosition.magnitude;
|
|
float intensity = StrengthAt(magnitude);
|
|
Vector3 intensity3 = localPosition.normalized * intensity;
|
|
return intensity3;
|
|
}
|
|
}
|
|
|
|
} |