Question by
basiakrzychu · Aug 14, 2018 at 10:48 PM ·
multiplayerrangelightsflashlightspot
UNET, flaslight's range and spot
Hi, I am creating simple game around lights. I want it to be multiplayer game. I encountered a problem with changing spot and range of light. The light is only changes are only showing on local player, but not on others clients.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class flashlight : NetworkBehaviour {
public Light swiatlo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (hasAuthority == false)
{
return;
}
if (Input.GetAxis("Mouse ScrollWheel") != 0f)
{
CmdLightRange();
}
}
[Command]
public void CmdLightRange()
{
RpcLightRange();
}
[ClientRpc]
private void RpcLightRange()
{
swiatlo.range += Input.GetAxis("Mouse ScrollWheel");
swiatlo.spotAngle -= 10 * Input.GetAxis("Mouse ScrollWheel");
}
}
Making light for example enabled or other things work. Flaslight is a child of player prefab.
Comment
Your answer
Follow this Question
Related Questions
MultiplayerFPS - database error 1 Answer
Can't connect to server by android phone 0 Answers
Failed receiving RPC batch index 0 Answers
Unity and Photon Question 0 Answers
Having Trouble Connecting With UNet 0 Answers