Synchronize Player Hit with Mouse

Options
Hey guys!
Im pretty new to Photon und im trying to make a topdown shooter (just for fun).
My problem now is, that i want to synchronize if the player clicked on an object (which has a rigidbody) so the shot will travel there.
The problem I am having is, that i dont want to use IPunObservable on the mouseposition of the player cause it sounds costly. (i have done a raycast through the mouseposition and checks if it hits something)
I dont know how I can send the Information of hitting the object to the other players.
(If the player hits a object, a raycast is sent from playerpos to objectpos)

Thanks a lot!

Comments

  • Nori_SC
    Options
    RPC ?
  • Well i dont know how this is possible with rpc, i never geht the mouseposition of the other player (only of the local player).
    Here is the part i have the problems with:
    Ray camRay = Camera.main.ScreenPointToRay(mousePosition); if (Physics.Raycast(camRay, out objHit, 200f, shootableMask)) { if (objHit.collider.GetComponent<Rigidbody>() != null) { targetObjectHit = true; shootRay.direction = new Vector3(objHit.point.x - transform.position.x, objHit.transform.position.y - transform.position.y, objHit.point.z - transform.position.z); shootDirection = shootRay.direction; pV.RPC("ShootVisual", RpcTarget.All); } else { noTargetHit = true; shootRay.direction = transform.forward; pV.RPC("ShootVisual", RpcTarget.All); }

    The Problem i have is, the ShootDirection is not known by the other player, so in the second part, where the linerenderer is instantiated, it cant do this, because there is no shotDirection on the onlinePlayer side.