- Home /
[Command] tag not working
I have a game that works over my LAN network. Movement and everything works fine right now, but I'm having trouble with the [Command] tag. Here is my script:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class Flashlight : NetworkBehaviour
{
public GameObject Light;
[Command]
public void CmdToggleLight()
{
Light.SetActive(!Light.activeInHiearchy);
}
void Update()
{
if(!isLocalPlayer)
{
return;
}
if(Input.GetKeyDown(Keycode.Mouse0))
{
CmdToggleLight();
}
}
}
The problem I have is that the host can turn their light on, but the client doesn't see it turn on. Also, the client can't turn their light on (even on client side). How would I fix this to work on both the client and the host? Am I using the [Command] attribute correctly?
Note: I'm using HLAPI Pro because originally when I was testing this UNET started giving me errors caused from Unity Bugs. Here's a link to HLAPI Pro: https://forum.unity.com/threads/unet-hlapi-pro-taking-unet-to-the-next-level.425437/ (I'm using unity 2017.3)
Your answer
Follow this Question
Related Questions
Simple activation network script 0 Answers
Can't access "NetworkServer" 0 Answers
Problems with Network.destroy 1 Answer
How do I get the network delay between server and client? 1 Answer
Custom Network Manager 0 Answers