private void GroundedState() { _jumpPoint = _body.position; _vectorUpDelta = _character.Pivot.position - _body.position; _maxDistance = _vectorUpDelta.magnitude; _vectorUp = _vectorUpDelta.normalized; _currentForce = _vectorUp * JumpForce; _currentState = AbilityInternalState.Processing; }
private void AiredState() { _body.position += _currentForce * Time.deltaTime; _currentForce += (-_vectorUp * Gravity); if (Vector3.Distance(_body.position, _character.Pivot.position) >= _maxDistance) { _body.position = _jumpPoint; _currentState = AbilityInternalState.Deactivate; } }
private void ProcessingState() { _body.position += _currentForce * Time.deltaTime; if (Vector3.Distance(_body.position, pivot) >= _maxDistance) { _character.CurrentAngle += 180; _character.Pivot.localRotation = Quaternion.Euler(0, 0, _character.CurrentAngle); _body.position = _targetPosition; _currentState = AbilityInternalState.Deactivate; } }
public override void Initialize(Character character) { base.Initialize(character); // Setting up the simple static state machine _stateMachine = new StateMachineDelegate[(int)AbilityInternalState.Count]; _stateMachine[(int)AbilityInternalState.Starting] = StartingState; _stateMachine[(int)AbilityInternalState.Processing] = ProcessingState; _stateMachine[(int)AbilityInternalState.Deactivate] = DeactivateState; _currentState = AbilityInternalState.Starting; _body = character.Model; }
private void StartingState() { // Calculates the vector from the model position to the // pivot point, and calculates where should be the target // position where the character is moving pivot = _character.Pivot.position; pivot.z = _body.position.z; _vectorUpDelta = pivot - _body.position; _targetPosition = _body.position + (2 * _vectorUpDelta); _maxDistance = _vectorUpDelta.magnitude; _vectorUp = _vectorUpDelta.normalized; _currentForce = _vectorUp * ChangeSpeed; _currentState = AbilityInternalState.Processing; }
private void DeactivateState() { enabled = false; _currentState = AbilityInternalState.Starting; }