Example #1
0
    void Update()
    {
        PlayerTransform.initialPos = transform.position;
        CheckLineOfSight();
        CheckForPause();
        CheckStates();
        GetDirection();
        CheckHealth();

        if (currentState == PlayerState.Idle || currentState == PlayerState.Walk || currentState == PlayerState.Run)
        {
            position = new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0).normalized;
        }

        //If there's input...
        if (position != Vector3.zero)
        {
            horizontalspeed = position.x;
            verticalspeed   = position.y;
            playerAnim.AnimSpeed(horizontalspeed, verticalspeed);             //Anim speed

            //Run
            if (currentState == PlayerState.Idle)
            {
                currentState = PlayerState.Run;
            }
        }
    }