Ejemplo n.º 1
0
    void Update()
    {
        // Store the input axes.
        h = Input.GetAxis("Horizontal");
        v = Input.GetAxis("Vertical");

        // Set the input axes on the Animator Controller.
        anim.SetFloat(hFloat, h, 0.1f, Time.deltaTime);
        anim.SetFloat(vFloat, v, 0.1f, Time.deltaTime);

        // Toggle sprint by input.
        sprint = Input.GetButton(sprintButton);

        // Set the correct camera FOV for sprint mode.
        if (IsSprinting())
        {
            changedFOV = true;
            camScript.SetFOV(sprintFOV);
        }
        else if (changedFOV)
        {
            camScript.ResetFOV();
            changedFOV = false;
        }
        // Set the grounded test on the Animator Controller.
        anim.SetBool(groundedBool, IsGrounded());
    }
Ejemplo n.º 2
0
    void Update()
    {
        h = Input.GetAxis("Horizontal");
        v = Input.GetAxis("Vertical");


        anim.SetFloat(hFloat, h, 0.1f, Time.deltaTime);
        anim.SetFloat(vFloat, v, 0.1f, Time.deltaTime);


        sprint = Input.GetKey(KeyCode.LeftShift);


        if (IsSprinting())
        {
            changedFOV = true;
            camScript.SetFOV(sprintFOV);
        }
        else if (changedFOV)
        {
            camScript.ResetFOV();
            changedFOV = false;
        }
        anim.SetBool(groundedBool, IsGrounded());
    }
Ejemplo n.º 3
0
    void Update()
    {
        // Store the input axes.
        h = XCI.GetAxis(XboxAxis.LeftStickX, joystick);
        v = XCI.GetAxis(XboxAxis.LeftStickY, joystick);

        // Set the input axes on the Animator Controller.
        anim.SetFloat(hFloat, h, 0.1f, Time.deltaTime);
        anim.SetFloat(vFloat, v, 0.1f, Time.deltaTime);

        // Toggle sprint by input.
        sprint = XCI.GetDPad(XboxDPad.Up, joystick);

        // Set the correct camera FOV for sprint mode.
        if (IsSprinting())
        {
            changedFOV = true;
            camScript.SetFOV(sprintFOV);
        }
        else if (changedFOV)
        {
            camScript.ResetFOV();
            changedFOV = false;
        }
        // Set the grounded test on the Animator Controller.
        anim.SetBool(groundedBool, IsGrounded());

        if (IsGrounded())
        {
            GetRigidBody.drag = 0;
        }
    }
Ejemplo n.º 4
0
    void Update()
    {
        h = ExternalInput.x + MoveInput.x;
        v = ExternalInput.y + MoveInput.y;
        if (!ExternalInputOverride && MoveInput == Vector2.zero)
        {
            h = Input.GetAxis("Horizontal") / 2;
            v = Input.GetAxis("Vertical") / 2;

            var accel = Input.acceleration.x / 2;

            if (AccelerationInput)
            {
                if (Mathf.Abs(accel) > 0.8f)
                {
                    h -= Input.acceleration.x;
                }
            }
        }

        // Set the input axes on the Animator Controller.
        anim.SetFloat(hFloat, h, 0.1f, Time.deltaTime);
        anim.SetFloat(vFloat, v, 0.1f, Time.deltaTime);

        // Toggle sprint by input.
        sprint = Input.GetButton(sprintButton);

        // Set the correct camera FOV for sprint mode.
        if (IsSprinting())
        {
            changedFOV = true;
            if (camScript)
            {
                camScript.SetFOV(sprintFOV);
            }
        }
        else if (changedFOV)
        {
            if (camScript)
            {
                camScript.ResetFOV();
            }
            changedFOV = false;
        }
        // Set the grounded test on the Animator Controller.
        anim.SetBool(groundedBool, IsGrounded());
    }
Ejemplo n.º 5
0
    void Update()
    {
        if (initialized)
        {
            // Store the input axes.
            // h = Input.GetAxis("Horizontal");
            // v = Input.GetAxis("Vertical");
            //
            // // Set the input axes on the Animator Controller.
            // anim.SetFloat("H", h, 0.1f, Time.deltaTime);
            // anim.SetFloat("V", v, 0.1f, Time.deltaTime);
            //Jedium
            //  h = Input.GetAxisRaw("Horizontal");
            //  v = Input.GetAxisRaw("Vertical");
            // anim.SetFloat(hFloat, h);
            // anim.SetFloat(vFloat, v);
            // anim.SetVH(v,h);

            // Toggle sprint by input.
            sprint = Input.GetButton(sprintButton);

            // Set the correct camera FOV for sprint mode.
            if (IsSprinting())
            {
                changedFOV = true;
                camScript.SetFOV(sprintFOV);
            }
            else if (changedFOV)
            {
                camScript.ResetFOV();
                changedFOV = false;
            }

            // Set the grounded test on the Animator Controller.
            unityAnim.SetBool("Grounded", IsGrounded());
        }
        else
        {
            Init();
        }
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Attack") && !anim.GetBool("Attack"))
        {
            anim.SetBool("Attack", true);
        }
        else if (Input.GetButtonDown("Attack") && !anim.GetBool("ContinueAttack"))
        {
            anim.SetBool("ContinueAttack", true);
        }

        if (!canMove)
        {
            return;
        }

        h = Input.GetAxis("Horizontal");
        v = Input.GetAxis("Vertical");

        if (Input.GetButtonDown("Sprint") && anim.GetBool("Grounded") && canDash && lob.isLockOn)
        {
            anim.SetTrigger("Dash");
            canDashDelayer = 0;
            canDash        = false;
        }

        if (!canDash)
        {
            if (canDashDelayer <= (21f / 60f))
            {
                canDashDelayer += Time.deltaTime;
            }
            else
            {
                canDash = true;
            }
        }

        isSprint = (Input.GetButton("Sprint"));

        if (isSprint)
        {
            float speed;
            if (h == 0 && v == 0)
            {
                speed = 0;
            }
            else
            {
                speed = (Mathf.Abs(h) + Mathf.Abs(v)) / (Mathf.Abs(h) + Mathf.Abs(v)) * 2;
            }
            float actualSpeed = Mathf.Lerp(anim.GetFloat("Speed"), speed, .1f);
            anim.SetFloat("Speed", actualSpeed);

            if (!lob.isLockOn)
            {
                tob.SetFOV(100f);
            }
        }
        else
        {
            float speed;
            if (h == 0 && v == 0)
            {
                speed = 0;
            }
            else
            {
                speed = (Mathf.Abs(h) + Mathf.Abs(v)) / (Mathf.Abs(h) + Mathf.Abs(v));
            }
            float actualSpeed = Mathf.Lerp(anim.GetFloat("Speed"), speed, .1f);
            anim.SetFloat("Speed", actualSpeed);

            tob.ResetFOV();
        }

        anim.SetFloat("H", h);
        anim.SetFloat("V", v);

        if (Input.GetButtonDown("Jump") && isGrounded && !anim.GetCurrentAnimatorStateInfo(0).IsName("Land") && !anim.GetBool("Attack"))
        {
            jump = true;
        }
    }