So I have an object called Koth Pole. I want to put it in the inspector variable KOTH Pole, but when I try to do so, it has the dark circle with a line slashed through it! Anyone know why I can’t do it?
The script with KOTH Pole variable.
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;
public GameObject KOTHPole;
public KothPoleHealth kothHealth;
[SerializeField]
private Camera cam;
[SerializeField]
private LayerMask mask;
void Start()
{
// if (PolePlacer.ourPole != null)
// {
// PolePlacer.ourPole = theKothPole;
// }
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);
// PlayerShot (_hit.collider.name, weapon.damage);
}
}
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, range, mask))
{
if (_hit.collider.tag == POLE_TAG)
{
print ("hit pole");
CmdServerCallRpcPoleDamage (damage);
// PlayerShot (_hit.collider.name, weapon.damage);
}
}
}
[Command]
void CmdServerCallRpc (string _playerID, int _damage)
{
RpcServerPlayerShot (_playerID,_damage);
}
[Command]
void CmdServerCallRpcPoleDamage (int _damage)
{
RpcServerPoleShot (_damage);
}
[ClientRpc]
void RpcServerPlayerShot (string _playerID, int _damage)
{
Debug.Log (_playerID + " has been shot.");
Player _player = GameManager.GetPlayer (_playerID);
_player.RpcTakeDamage (_damage);
}
[ClientRpc]
void RpcServerPoleShot (int _damage)
{
kothHealth = KOTHPole.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);
// }
}
P.S. The object I want as the variable is in the game, while the object with the script is a prefab in assets, and if I bring the prefab into the game I can set the variable, but not when in asset folder!