/**
     * Implements the moving logic
     */
    private void Move(bool enableVertical, bool enableHorizontal)
    {
        _vertical   = (enableVertical) ? Input.GetVertical() : 0;
        _horizontal = (enableHorizontal) ? Input.GetHorizontal() : 0;

        // If we are pulling a box and trying to move in the pulling direction, we instruct the box to pull
        if (_playerState == PlayerState.pulling && DoesMoveInPullDirection())
        {
            _pushableToPull.Pull(viewDirection.Inverse(), this);
        }

        // Otherwise, move normally
        else
        {
            // Scale movement speed by the input axis value and the passed time to get a delta which must be applied to the current position
            Vector2 deltaPosition = new Vector2(
                _horizontal,
                _vertical
                ) * (speed * Time.deltaTime);

            if (!Mathf.Approximately(deltaPosition.x, 0.0f) || !Mathf.Approximately(deltaPosition.y, 0.0f))
            {
                _lookDirection.Set(deltaPosition.x, deltaPosition.y);
                _lookDirection.Normalize();
            }

            Animator.SetFloat(LookXProperty, _lookDirection.x);
            Animator.SetFloat(LookYProperty, _lookDirection.y);
            Animator.SetFloat(SpeedProperty, deltaPosition.magnitude);

            PhysicsEffects.MoveBody(
                Rigidbody2D.position + deltaPosition
                );
        }
    }
Beispiel #2
0
 void FixedUpdate()
 {
     if (!explosion)
     {
         _effects.MoveBody(_rigidbody2D.position);
     }
 }
Beispiel #3
0
    void FixedUpdate()
    {
        if (!isDead)
        {
            Vector2 position = Rigidbody2D.position;
            position += ComputeOffset();

            PhysicsEffects.MoveBody(position);
        }
    }
Beispiel #4
0
    void FixedUpdate()
    {
        // if we still have living player to follow, move around, else exorcise/respawn
        if (!_exorcised && GetFollowedPlayer() is PlayerController followedPlayer)
        {
            if (_moveArround)
            {
                _angle += RotateSpeed * Time.deltaTime;

                var position  = _rigidbody2D.position;
                var rotation  = new Vector2(Mathf.Sin(_angle), Mathf.Cos(_angle)) * (Radius * rMod);
                var direction = (followedPlayer.Center - position) * Time.deltaTime;

                position += direction + rotation;
                _physicsEffects.MoveBody(position);

                _animator.SetFloat(MoveXProperty, direction.x);
            }
        }
        else
        {
            Exorcise();
        }
    }
 void FixedUpdate()
 {
     _physicsEffects.MoveBody(_rigidbody2D.position + Time.deltaTime * thrust * _direction);
 }