- Home /
Flashlight on and everyone sees it ?
i have a problem with my script i want everyone connected to see the flashlight on when a player presses "f" here is my script
#pragma strict
var on : boolean = false;
var on1 : boolean = false;
function Update () {
if(networkView.isMine == true){
if(Input.GetKeyDown("f")){
if(on == false){
turnon();
}
if(on == true){
turnoff();
}
}
}
if(on1 == true){
gameObject.light.enabled = true;
on = true;
}
if(on1 == false){
gameObject.light.enabled = false;
on = false;
}
if(networkView.isMine == false){
if(on1 == true){
gameObject.light.enabled = true;
}
if(on1 == false){
gameObject.light.enabled = false;
}
}
}
function turnon () {
if(networkView.light){
on1 = true;
}
}
function turnoff () {
if(networkView.light){
on1 = false;
}
}
an example would be helpful!
Include your flashlight in the player prefab and instantiate it in the network view.
ok i have it in a prefab and i dont know how to instantiate it in the network view..
If you have your controller (character) instantiated, you could make your Flashlight object (and the scripts attached to it) instantiated as well by making your flashlight a child of the controller prefab/object.
Answer by iwaldrop · Jul 01, 2013 at 10:53 PM
You probably need to make an RPC call in order to tell the flashlight to actually 'turn on' on the client machines.
Your answer
Follow this Question
Related Questions
View ID AllocatedID: # not found during lookup. Strange behaviour may occur 1 Answer
Networking dupplicate processing of components 0 Answers
Photon Unity Networking fix physics delay 0 Answers
Sending and receiving variables trough network? 2 Answers
Can I delay the instantiation of the network objects? 1 Answer