Movement

I was looking up ways for movement and used this for the RPG project a while back, a code from a video I saw, works for the targeting movement. Going to do the same for the free look movement too. The GetInput.

public override void Tick(float deltaTime)

    {

        if (stateMachine.Targeter.CurrentTarget == null)

        {

            stateMachine.SwitchState(new PlayerFreeLookState(stateMachine));

            return;

        }

        Vector3 movement = CalculateMovment();

        Move(movement * stateMachine.TargetingMovementSpeed, deltaTime);

        UpdateAnimatorTest(GetInput(), deltaTime);

       // UpdateAnimator(deltaTime);

        FaceTarget();

    }
private Vector2 GetInput()

    {

        Vector2 input = new Vector2

        {

           y = stateMachine.InputReader.MovementValue.y,

           x = stateMachine.InputReader.MovementValue.x

        };

        return input;

    }

    private void UpdateAnimatorTest(Vector2 input, float deltaTime)

    {

        stateMachine.Animator.SetFloat(TargetingRightHash, input.x, 0.1f, deltaTime);

        stateMachine.Animator.SetFloat(TargetingForwardHash, input.y, 0.1f, deltaTime);

    }

Privacy & Terms