Search Unity

Instantiating hitpoint debris/blood/fx with photon ? (multiplayer game)

Discussion in 'Scripting' started by Jeepster, May 29, 2019.

  1. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    401
    Hi,

    This is my original code to instantiate an effect wherever my raycast hits and it works, but only on my players screen as it isn't sent over the network with photon. I've looked into PhotonNetwork.Instantiate but I can't get it to work as it has to happen on the "hitpoint" in real time:

    Code (CSharp):
    1.      
    2.         Ray ray = new Ray(RootToShoot.transform.position, RootToShoot.transform.forward);
    3.         Transform hitTransform;
    4.         Vector3 hitPoint;
    5.      
    6.    
    7.  
    8.         hitTransform = FindClosestHitObject(ray, out hitPoint);
    9.         if (hitTransform != null)
    10.         {
    11.  
    12.  
    13.         if (hitTransform.gameObject.tag == "rock")
    14.  
    15.             {
    16.                 GameObject impactGO = Instantiate(impactEffectrock, hitPoint, transform.rotation);
    17.                 Destroy(impactGO, 1f);
    18.             }
    The raycast, however, is visible over the network as I used [PunRPC] on this shooting function. I wonder how to instantiate the hitpoint effects over the network based on the code above. Can anyone help me with this? It would be very much appreciated.
     
  2. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    401
  3. Jeepster

    Jeepster

    Joined:
    Jan 23, 2014
    Posts:
    401
    Can nobody help with this issue? I'd really appreciate the help