public override void Update() { _elapseTime += Time.deltaTime; if (_elapseTime >= _hideTime) { _owner.SwitchState(StateDefinition.StateName.GetBall); } if (CloseBall()) { _owner.SwitchState(StateDefinition.StateName.GetBall); } // if at position, go to a different one // if (Vector3.Distance(_targetLocation, _owner.transform.position) < 0.3f) { _targetLocation = GetNewLocation(); } // move to hide position // Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _targetLocation); _owner.MoveForward(direction.normalized); }
public override void OnUpdate() { _elapseTime += Time.deltaTime; Transform closestBall = NearestBall(_owner.balls); _owner.targetBall = closestBall; if (_owner.targetBall != null) { Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position); if (!_owner.hasBall) { _owner.MoveForward(direction.normalized); if (Vector3.Distance(_owner.transform.position, _owner.targetBall.position) < 1.5f) { _owner.Pickup(); _owner.SwitchState(Definitions.StateName.Attack); } } } if (!closestBall) { //_owner.SwitchState(Definitions.StateName.Defense); } }
public override void OnUpdate() { _elapseTime += Time.deltaTime; Transform closestTarget = NearestTarget(_owner.targets); _owner.targetAgent = closestTarget; if (_owner.targetAgent != null) { if (Vector3.Distance(_owner.transform.position, _owner.targetAgent.position) < Mathf.Infinity) { Throw(); _owner.SwitchState(Definitions.StateName.Defense); } else { Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position); _owner.MoveForward(direction); } } }
public override void Update() { _elapsedTime += Time.deltaTime; Transform closestBall = GetClosestBall(); if (closestBall == null) { _owner.SwitchState(StateDefinition.StateName.Hide); } _owner.targetBall = closestBall; if (_owner.targetBall != null) { Vector3 direction = _owner.GetDirectionToTarget(_owner.transform.position, _owner.targetBall.position); if (!_owner.hasBall) { _owner.MoveForward(direction.normalized); CanGrabBall(); } } }