Пример #1
0
    void FixedUpdate()
    {
        float h = Input.GetAxisRaw("Horizontal_" + ControllerIndex);
        float v = Input.GetAxisRaw("Vertical_keyboard_" + ControllerIndex);

        if (v == .0f)
        {
            v = -Input.GetAxisRaw("Vertical_gamepad_" + ControllerIndex);
        }


        rb2d.velocity = new Vector2(h * hMaxSpeed * movementSpeedCoefficient,
                                    v * vMaxSpeed * movementSpeedCoefficient);
        if (Mathf.Abs(h) > 0 || Mathf.Abs(v) > 0)
        {
            GetComponent <Animator>().SetBool("IsMoving", true);
        }
        else
        {
            GetComponent <Animator>().SetBool("IsMoving", false);
        }

        if (Input.GetButton("Fire_" + ControllerIndex))
        {
            weapon.fire();
        }
    }
 void Update()
 {
     if (health <= 0)
     {
         StartCoroutine("kill");
     }
     if (weapon != null)
     {
         weapon.fire();
     }
 }