So I have seen this error many times before, and have easily been able to fix it… until now. I don’t see anything wrong! Is it obvious and I am just overlooking something?
using UnityEngine;
using UnityEngine.Networking;
public class PlayerShoot : NetworkBehaviour {
private const string PLAYER_TAG = "Player";
private const string POLE_TAG = "HillObject";
public static int damage;
public static float range;
[SerializeField]
public GameObject KOTHPole;
public KothPoleHealth kothHealth;
[SerializeField]
private Camera cam;
[SerializeField]
private LayerMask mask;
void Start()
{
range = 10000f;
if (cam == null)
{
Debug.LogError ("PlayerShoot: No camera referenced!");
this.enabled = false;
}
}
void Update()
{
if (Input.GetButtonDown ("left click"))
{
Shoot ();
}
}
[Client]
void Shoot()
{
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, range, mask))
{
if (_hit.collider.tag == PLAYER_TAG)
{
CmdServerCallRpc (_hit.collider.name, damage);
}
}
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, range, mask))
{
if (_hit.collider.tag == POLE_TAG)
{
CmdServerCallRpcPoleDamage (_hit.collider.gameObject, damage);
}
}
}
[Command]
void CmdServerCallRpc (string _playerID, int _damage)
{
RpcServerPlayerShot (_playerID,_damage);
}
[Command]
void CmdServerCallRpcPoleDamage (GameObject _pole, int _damage)
{
RpcServerPoleShot (_pole, _damage);
print (_pole.name);
}
[ClientRpc]
void RpcServerPlayerShot (string _playerID, int _damage)
{
Debug.Log (_playerID + " has been shot.");
Player _player = GameManager.GetPlayer (_playerID);
_player.RpcTakeDamage (_damage);
}
[ClientRpc]
void RpcServerPoleShot (GameObject _pole, int _damage)
{
kothHealth = _pole.GetComponent<KothPoleHealth> ();
kothHealth.RpcTakePoleHealth (_damage);
}
// void PlayerShot (string _playerID, int _damage)
// {
// Debug.Log (_playerID + " has been shot.");
//
// Player _player = GameManager.GetPlayer (_playerID);
// _player.RpcTakeDamage(_damage);
// }
}
Error on Line 93