public override void OnExcuteWithEvent(OrdinaryEnemyTop fsm) { fsm.Velocity = Vector2.zero; if (fsm.ChaseProcess()) { return; } if (!fsm.InRadius(0.2f)) { fsm.ChangeState <ReturnState>(null); } }
public override void OnExcuteWithEvent(OrdinaryEnemyTop fsm) { if (fsm.ChaseProcess()) { return; } if (path.Finished) { fsm.ChangeState <HomeState>(null); return; } Vector2 dir = path.GetDir(); float dis = (fsm.mov.Position - fsm.originPos).magnitude; float speed = fsm.returnDistanceSpeedCurve.Evaluate(dis); fsm.mov.Velocity = dir.normalized * speed; }