using UnityEngine;
using System.Collections;
public class Weapon : MonoBehaviour {
public string Name;
public int RateOfFire;
int ROF;
public int Accuracy;
public int Ammo;
public Bullet Amunition;
public PCP shootingPoint;
[HideInInspector]
public bool IsActive = false;
void Start ()
{
ROF = 0;
}
// Update is called once per frame
public void WeaponUpdate ()
{
if(ROF != 0)
{
ROF --;
}
}
public void Shoot()
{
if(Ammo > 0 && ROF == 0)
{
shootingPoint.SendMessage("Create",Amunition);
Ammo --;
ROF = RateOfFire;
}
}
}
"注意:PCP是Prefab Shooting Point"的快捷方式。
我在拍摄方法中遇到了这个错误" shootingPoint.SendMessage"我只是不明白为什么?而且我在射击点和弹药放置的物体上有组件,那有什么不对?
这是一张证明我附加物品的图像:
答案 0 :(得分:0)
shootPoint或Amunition尚未成为对象。他们是该行中唯一可能导致问题的两件事。