- Home /
isLocalPlayer does not exist in the current context
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."
Here is the code
using UnityEngine.Networking; using System; using UnityEngine;
public class Weapon$$anonymous$$anager : $$anonymous$$onoBehaviour {
[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 = Layer$$anonymous$$ask.NameToLayer(weaponLayerName);
}
}
Answer by Zee_pso · Mar 23, 2018 at 01:28 AM
You need to extend the class to be a NetworkBehaviour, not a MonoBehaviour.
// Example
public class WeaponManager : NetworkBehaviour {
// etc....
}
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Still getting BroadcastMessage has no receiver error. 1 Answer
Control objects in one level but in 2 monitor! 1 Answer
CommandAttribute ( [Command] ) Limitations? 1 Answer
networkview + GUI 2 Answers