Hi ![]()
This is a bit unusual of a problem. In my multiplayer game - Each player is setup to call an instantiation function in another script with a “hit effect” when the raycast hits either the ground or some water. And it works, but only when the player who’s shooting the raycast, isn’t higher up then ca. 3 on the Y-axis. I have no idea why this is, the prefab objects with the particles instantiate as they should and at great distance, but if the player is on a slope or in the air and above 3 on the Y-axis, nothing is instantiated even though the raycast hit is stil recorded. Anybody ever had this problem?
Here’s my code for shooting that each player has:
Ray ray = new Ray(RootToShoot.transform.position, RootToShoot.transform.forward);
Transform hitTransform;
Vector3 hitPoint;
hitTransform = FindClosestHitObject(ray, out hitPoint);
if (hitTransform != null)
{
Debug.Log("We hit: " + hitTransform.name);
if (hitTransform.gameObject.tag == "rock")
{
fxManager.GetComponent<PhotonView>().RPC("RockSplash", PhotonTargets.All, transform.position, hitPoint, transform.rotation);
}
}
This shooting code calls a function “RockSplash” from a script named fxManager located in each scenes/levels wherein the instantion code lies. Here’s the fxManager code:
[PunRPC]
void RockSplash(Vector3 startPos, Vector3 endPos, Quaternion rotation)
{
PhotonView pvw = impactEffectrock.GetComponent<PhotonView>();
if (pvw == null)
{
Debug.LogError("Missing PhotonView script");
}
if (pvw != null)
{
GameObject impactGO = (GameObject)Instantiate(impactEffectrock, endPos, rotation);
GameObject impactGO1 = (GameObject)Instantiate(impactEffectSPARK, endPos, rotation);
Destroy(impactGO, 1f);
Destroy(impactGO1, 1f);
}
}
Nowhere in this code do I specify a height from which the instantiation should stop working. Does anyone see what’s wrong? All help would be greatly appreciated