Changing my Raycast code

Hi

This is my raycast code when a spawned player in my multiplayer game shoots. It shoots out the raycast and stores the hitpoint and then it instantiates a visual effect on impact at that hitpoint:

Ray ray = new Ray(cam.transform.position, cam.transform.forward);
Transform hitTransform;
Vector3 hitPoint;
//if (Physics.Raycast(ray, out hitInfo))
//{
// Debug.Log("We hit: " + hitInfo.collider.name);
//}

hitTransform = FindClosestHitObject(ray, out hitPoint);
if (hitTransform != null)
{
Debug.Log("We hit: " + hitTransform.name);


if (hitTransform.gameObject.tag == "rock")

{
GameObject impactGO = Instantiate(impactEffectrock, hitPoint, transform.rotation);
Destroy(impactGO, 1f);
}
}


The problem is that the "impactGO" isn't instantiated with PhotonNetwork.Instantiate() and no-one else can see it. Can anyone tell me how to write my instantiation line so that it's visible to all. i.e. this line? :
GameObject impactGO = Instantiate(impactEffectrock, hitPoint, transform.rotation);
Destroy(impactGO, 1f);

I would really appreciate the help.

Comments