Я создал код на смену оружия по нажатию кнопки
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeaponChange : MonoBehaviour
{
public GameObject weapon1;
public GameObject weapon2;
public GameObject weapon3;
public int MaxWeapon = 3;
private int Guns;
// Update is called once per frame
void Update()
{
if(Guns == 0)
{
weapon1.SetActive(true);
weapon2.SetActive(false);
weapon3.SetActive(false);
}
if (Guns == 1)
{
weapon1.SetActive(false);
weapon2.SetActive(true);
weapon3.SetActive(false);
}
if (Guns == 2)
{
weapon1.SetActive(false);
weapon2.SetActive(false);
weapon3.SetActive(true);
}
if(Guns <= 0)
{
Guns = 0;
}
if(Guns >= MaxWeapon)
{
Guns = MaxWeapon;
}
if (Input.GetKeyDown ("E") > 0f) //В чём ошибка?
{
Guns += 1;
}
if (Input.GetKeyDown ("Q") < 0f) //В чём ошибка?
{
Guns -= 1;
}
}
}
И мне юнити выдаёт ошибку
Assets\WeaponChange.cs(46,13): error CS0019: Operator '<' cannot be applied to operands of type 'bool' and 'float'
Assets\WeaponChange.cs(46,13): error CS0019: Operator '>' cannot be applied to operands of type 'bool' and 'float'
Как её исправить?