- Home /
Question by
dimitris0326 · Jan 12 at 12:16 AM ·
multiplayerphoton
Raycast works only in editor
Hey, i am having a problem with photon pun 2 and RPC. When I connect from editor and from a build and try to shoot (from the editor) in console I get 2 messages as expected but when I shoot from the build I get only 1 message you will understand from the following code!
using UnityEngine;
using Photon.Pun;
public class TryingToShoot : MonoBehaviourPun
{
public Transform origin;
PhotonView pv;
void Start()
{
pv = GetComponent<PhotonView>();
}
void Update()
{
if (!GetComponent<PhotonView>().IsMine)
return;
else if (Input.GetMouseButtonDown(0))
pv .RPC("Rpc_Casting", RpcTarget.All);
}
[PunRPC] public void Rpc_Casting()
{
RaycastHit hit;
Debug.Log(GetComponent<PhotonView>().ViewID + " Is Trying To Shoot");
if (Physics.Raycast(origin.transform.position, origin.transform.TransformDirection(Vector3.forward), out hit, 1000))
Debug.Log(GetComponent<PhotonView>().ViewID + " Hit!");
}
}
Comment
Answer by dimitris0326 · Jan 16 at 01:30 AM
I found out that the hits are registered correctly, its just that Debug.log doesn't work.
Your answer
Follow this Question
Related Questions
Photon - How to name a player? 0 Answers
Photon : Multiplayer car race game Camera Set 0 Answers
Photon Network Muzzleflash 0 Answers
Photon Unity multiplayer player name issue (worldtoscreenpoint?) 0 Answers
Player Smoothness across network (PUN) 0 Answers