我在这个脚本中遇到错误?
UnityEngine 不包含刚体的定义(行:22,24)
public class GunShoot : MonoBehaviour
{
public GameObject BulletPrefab;
public float BulletSpeed;
public int BulletsInClip;
public AudioClip GunshotSound;
void Update () {
if (Input.GetButtonDown("Shoot")){
Shoot();
}
}
void Shoot() {
var bullet = Instantiate(BulletPrefab, transform.Find("BulletSpawn").position, transform.Find("BulletSpawn").rotation);
bullet.rigidbody.AddForce(transform.forward * BulletSpeed);
audio.PlayOneShot(GunshotSound);
BulletsInClip--;
}
}