Question by
unity_yVY1fAOHHwGZKQ · Mar 30, 2021 at 10:18 AM ·
photonrpc
Photon RPC doesn't work ,It's only works in local
private void Awake()
{
trackl = GameObject.Find("SM_Veh_German_Tank_01_Track_l");
trackr = GameObject.Find("SM_Veh_German_Tank_01_Track_r");
}
#region Movement
void moveGround()
{
if (Input.GetKey(KeyCode.W))
{
Speed += Time.deltaTime;
this.photonView.RPC("TrackchangeMapForward1", RpcTarget.All);
this.photonView.RPC("TrackchangeMapForward1", RpcTarget.MasterClient);
}
if (Input.GetKey(KeyCode.S))
{
Speed += Time.deltaTime;
this.photonView.RPC("TrackchangeMapBack1", RpcTarget.All);
this.photonView.RPC("TrackchangeMapBack1", RpcTarget.MasterClient);
}
if (Input.GetKey(KeyCode.A))
{
Speed += Time.deltaTime;
this.photonView.RPC("TrackchangeMapLeft1", RpcTarget.All);
this.photonView.RPC("TrackchangeMapLeft1", RpcTarget.MasterClient);
}
if (Input.GetKey(KeyCode.D))
{
Speed += Time.deltaTime;
this.photonView.RPC("TrackchangeMapRight1", RpcTarget.All);
this.photonView.RPC("TrackchangeMapRight1", RpcTarget.MasterClient);
}
}
#endregion
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
if (photonView.IsMine)
{
moveGround();
}
}
#region RPC
[PunRPC]
void TrackchangeMapForward1()
{
trackl.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, -Speed));
trackr.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, -Speed));
}
[PunRPC]
void TrackchangeMapBack1()
{
//Speed += Time.deltaTime;
trackl.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, Speed));
trackr.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, Speed));
}
[PunRPC]
void TrackchangeMapLeft1()
{
//Speed += Time.deltaTime;
trackl.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, Speed));
trackr.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, -Speed));
}
[PunRPC]
void TrackchangeMapRight1()
{
// Speed += Time.deltaTime;
trackl.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, -Speed));
trackr.GetComponent<Renderer>().material.SetTextureOffset("_MainTex", new Vector2(0, Speed));
}
#endregion
Comment
Your answer
Follow this Question
Related Questions
Unity3D photon. bool resets. 0 Answers
OnTriggerEnter worked only on master client 0 Answers