- Home /
renderer.enable = photon?
0n my objects I have included a script to enable/disable 2 points of weapons (sheathed and wielded)
in the game, over the network when I press the corresponding button to enable/disable the mesh' all players online follow the same protocol, and is not seen by other clients.
Rather than using a separate script on each object to renderer.enable should I be sending the object.renderer.enable through photon?
I'm a bit stumped by photon, and the internet is cluttered with threads that used to exist and don't now
Edit: After testing the suggestion below, I've dug up some information
The bottom of the window includes the error i'm receiving. I've looked this up, and it tells me I need to reference an object just like the error. I've tried instantiating the object i'm scripting on in multiple different fashions.
Still stuck
Use an RPC call.
pseudocode :
if ( Input )
{
photonView.RPC( "SetRenderer", PhotonTargets.All );
}
@RPC
function SetRenderer()
{
// change the renderer
}
Sweet, thanks! That helps... Now where should that work? Network view? Photon script? hierarchy-specific objects? third person controller?
I've added photonview to the object I'm scripting on, aswell as set observation to none.
using UnityEngine;
using System.Collections;
public class sheildWeild : $$anonymous$$onoBehaviour {
bool weild;
public static string setRenderer = "SetRenderer";
// Use this for initialization
void Start () {
//sheildWeild SHEILD = new sheildWeild();
//sheildWeild sheild = sheildWeild.Instantiate(sheildWeild);
//sheildWeild SHEILD = this.gameObject;
PhotonNetwork.AllocateViewID();
weild=true;
}
// Update is called once per frame
public void Update () {
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.BackQuote))
{
PhotonView.RPC("SetRenderer", RPC$$anonymous$$ode.AllBuffered, weild, transform);
//PhotonView.RPC("SetRenderer", PhotonPlayer.AllBuffered, null);
}
}
[RPC]
public static void SetRenderer(bool weild, Transform QRN){
if(weild==false)
{
QRN.renderer.enabled=true;
//renderer.enabled=true;
weild = true;
}
else
{
QRN.renderer.enabled=false;
weild = false;
}
}
}
error CS0120: An object reference is required to access non-static member 'PhotonView.RPC(string, PhotonPlayer, params object[])"
I've searched the CS0120 and it only explains passing a string's content through the parameter of params object[]. Here, i'm attempting to RPC the rendered state of the object. I'm about to start texturing models because I cannot seem to figure this out, and I have played around as you can tell from my script's comments
I got RPC working properly, but it sends in an odd fashion. All shields/swords are affected on all clients, or my shield affected on other's client, and other's shield affected on my screen (all from my keypress)
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Accessing a Parent's PhotonID from a child's script 0 Answers
Enabling component - Please help 1 Answer
Photon Unity Networking:How do i set it to only let players control themselves? 0 Answers
"NullReferenceException: Object reference not set to an instance of an object" 1 Answer