HitpointFX only works within a narrow angle of shooting?? (HELP)

Hi,

I’ve got a shooting script on the player, and a FX manager script in the scene. When the player shoots, a function from the FX manager script is called that spawns a hitpoint effect, but there’s something wrong.

The hitpointFX doesn’t spawn unless the shooter is really close to the ground or 0 on the Y-axis.

Here’s the shooting part of the shooting script that calls the RockSplash from the FX manager script:

    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.RockSplash(transform.position, hitPoint, Quaternion.identity);
     
            } 
}

Here’s the fxManager code the instantiates when called from the shooting script:

    void RockSplash(Vector3 startPos, Vector3 endPos, Quaternion rotation)
    {
            GameObject impactGO = (GameObject)Instantiate(impactEffectrock, endPos, rotation);
            GameObject impactGO1 = (GameObject)Instantiate(impactEffectSPARK, endPos, rotation);

            Destroy(impactGO, 1f);
            Destroy(impactGO1, 1f);
        }
    }

Why does this happen, I need the hitpointFx (RockSplash) to instantiate any time the player shoots form any angle or height, any help would be greatly appreciated.

BTW The Ray cast also has an effect (Line renderer) and that works in any angle and from any height the player shoots. it’s only the instantiated hotpoint effect that bugs…

Just like you did on line 9 in the top script, start printing stuff out in RockSplash in the bottom script, stuff like the position it spawned at.

Inside of RockSplash you can also call Debug.Break() and that will put the editor into pause mode (still running), allowing you to study your scene at leisure and find your missing objects. This is probably one of the most-powerful debugging utilities available in Unity for tracking down what is really happening in a scene.

1 Like

Oh awesome, I didn’t know about Debug.Break()
I figured out a way to make it work by not using the fx manager script on instantiating the hitpoint effect directlyfrom the shooting script. this is how it worked:

                GameObject GO = PhotonNetwork.Instantiate(impactEffectrock.name, hitPoint, Quaternion.identity, 0);

So I don’t know exactly what caused the issue, but Yaaay, Thanks again. You’re always helpful in this forum

1 Like