I have been following along on Brackey’s FPS in Unity tutorial and I am currently stuck on E12. The console says that “isLocalPlayer” is not defined even though I put “using UnityEngine.Networking”. I have provided my script as reference. It is probably because this video is 2 yrs old. Pls, help.,I have been following along on Brackey’s FPS in Unity tutorial and I am currently stuck on E12. The console says that “isLocalPlayer” is not defined even though I put “using UnityEngine.Networking”. I have provided my script as reference. It is probably because this video is 2 yrs old. Pls, help."
You need to extend the class to be a NetworkBehaviour, not a MonoBehaviour.
// Example
public class WeaponManager : NetworkBehaviour {
// etc....
}
Here is the code
using UnityEngine.Networking;
using System;
using UnityEngine;
public class WeaponManager : MonoBehaviour {
[SerializeField]
private string weaponLayerName = "Weapon";
[SerializeField]
private Transform weaponHolder;
[SerializeField]
private PlayerWeapon primaryWeapon;
private PlayerWeapon currentWeapon;
void Start ()
{
EquipWeapon(primaryWeapon);
}
public PlayerWeapon GetCurrentWeapon ()
{
return currentWeapon;
}
void EquipWeapon (PlayerWeapon _weapon)
{
currentWeapon = _weapon;
GameObject _weaponIns = (GameObject)Instantiate(_weapon.graphics, weaponHolder.position, weaponHolder.rotation);
_weaponIns.transform.SetParent(weaponHolder);
**if (isLocalPlayer)**
_weaponIns.layer = LayerMask.NameToLayer(weaponLayerName);
}
}