mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 01:15:43 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8479197684 | ||
|
|
caf334208e |
@@ -27,6 +27,12 @@ namespace eagle {
|
||||
"Per-prefab controller overrides (index matches animalPrefabs); takes priority over animatorController")]
|
||||
public RuntimeAnimatorController[] animatorControllers;
|
||||
|
||||
[Header("State Name Overrides")]
|
||||
[Tooltip("Override walk state name for prefabs with non-standard names (e.g. 'glide')")]
|
||||
public string walkStateName;
|
||||
[Tooltip("Override eat state name for prefabs with non-standard names (e.g. 'hiss')")]
|
||||
public string eatStateName;
|
||||
|
||||
[Header("Behavior Timing")]
|
||||
public float minIdleDuration = 1f;
|
||||
public float maxIdleDuration = 3f;
|
||||
@@ -53,7 +59,16 @@ namespace eagle {
|
||||
private static readonly int AttackHash = Animator.StringToHash("attack");
|
||||
private static readonly int DieHash = Animator.StringToHash("die");
|
||||
|
||||
void Start() { SpawnAnimals(); }
|
||||
private int _walkHash;
|
||||
private int _eatHash;
|
||||
|
||||
void Start() {
|
||||
_walkHash = string.IsNullOrEmpty(walkStateName) ? WalkHash
|
||||
: Animator.StringToHash(walkStateName);
|
||||
_eatHash = string.IsNullOrEmpty(eatStateName) ? EatHash
|
||||
: Animator.StringToHash(eatStateName);
|
||||
SpawnAnimals();
|
||||
}
|
||||
|
||||
private void SpawnAnimals() {
|
||||
if (animalPrefabs == null || animalPrefabs.Length == 0) { return; }
|
||||
@@ -177,7 +192,7 @@ namespace eagle {
|
||||
|
||||
animal.targetPosition = RandomWanderPoint();
|
||||
animal.state = AnimalStateType.Walking;
|
||||
if (animal.animator != null) { animal.animator.Play(WalkHash); }
|
||||
if (animal.animator != null) { animal.animator.Play(_walkHash); }
|
||||
|
||||
UpdateFacing(animal);
|
||||
}
|
||||
@@ -196,7 +211,7 @@ namespace eagle {
|
||||
animal.state = AnimalStateType.Action;
|
||||
animal.timer = actionDuration;
|
||||
if (animal.animator != null) {
|
||||
var actionHash = Random.value < 0.5f ? EatHash : AttackHash;
|
||||
var actionHash = Random.value < 0.5f ? _eatHash : AttackHash;
|
||||
animal.animator.Play(actionHash);
|
||||
}
|
||||
} else {
|
||||
@@ -233,10 +248,10 @@ namespace eagle {
|
||||
public void TestAllIdle() { ForEachAnimal(a => a.animator?.Play(IdleHash)); }
|
||||
|
||||
[ContextMenu("Test: All Walk")]
|
||||
public void TestAllWalk() { ForEachAnimal(a => a.animator?.Play(WalkHash)); }
|
||||
public void TestAllWalk() { ForEachAnimal(a => a.animator?.Play(_walkHash)); }
|
||||
|
||||
[ContextMenu("Test: All Eat")]
|
||||
public void TestAllEat() { ForEachAnimal(a => a.animator?.Play(EatHash)); }
|
||||
public void TestAllEat() { ForEachAnimal(a => a.animator?.Play(_eatHash)); }
|
||||
|
||||
[ContextMenu("Test: All Attack")]
|
||||
public void TestAllAttack() { ForEachAnimal(a => a.animator?.Play(AttackHash)); }
|
||||
|
||||
+2
@@ -54,6 +54,8 @@ MonoBehaviour:
|
||||
wanderRadius: 25
|
||||
moveSpeed: 15
|
||||
animalScale: 15
|
||||
walkStateName: glide
|
||||
eatStateName: hiss
|
||||
minIdleDuration: 1
|
||||
maxIdleDuration: 3
|
||||
actionChance: 0.3
|
||||
|
||||
Reference in New Issue
Block a user