1
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
public class AnimalRoamingState : MachineState {
|
||||
public Vector3 targetPosition;
|
||||
public string ToDefault = "Idle";
|
||||
public readonly AnimalMachine animal;
|
||||
public AnimalRoamingState(Machine machine) : base(machine) => animal = machine as AnimalMachine;
|
||||
|
||||
public override void Enter() {
|
||||
targetPosition = animal.movement.RandomTargetPosition();
|
||||
}
|
||||
|
||||
public override void Exit() {
|
||||
animal.movement.StopMoving();
|
||||
animal.animator.SetFloat("MoveSpeed", 0);
|
||||
}
|
||||
|
||||
public override void Trigger() {
|
||||
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
bool complete = animal.movement.UpdateMove(targetPosition);
|
||||
animal.animator.SetFloat("MoveSpeed", animal.movement.currentSpeed);
|
||||
if (complete) { animal.ChangeState(ToDefault); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user