Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        // Movement
        transform.Translate(new Vector3(pc.input.x, 0, pc.input.y) * speed * Time.fixedDeltaTime);
        xLook          -= pc.mouseMovement.y * mouseSense * Time.fixedDeltaTime;
        xLook           = Mathf.Clamp(xLook, yLookInterval.x, yLookInterval.y);
        cam.eulerAngles = new Vector3(xLook, cam.eulerAngles.y, cam.eulerAngles.z);
        transform.Rotate(Vector3.up, pc.mouseMovement.x * mouseSense * Time.fixedDeltaTime);

        // Attack
        if (pc.attacking)
        {
            Attack();
        }

        // Switch Weapon Handler
        if (pc.equipableSwitch < 0)
        {
            SwitchEquipable(inv.Prev());
            pc.equipableSwitch++;
        }
        else if (pc.equipableSwitch > 0)
        {
            SwitchEquipable(inv.Next());
            pc.equipableSwitch--;
        }

        // Animations
        if (!pc.input.Equals(Vector2.zero))
        {
            anim.SetBool("Walking", true);
        }
        else
        {
            anim.SetBool("Walking", false);
        }

        // Call currEquip FixedUpdate
        if (currEquip != null)
        {
            currEquip.FixedUpdate();
        }
    }