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.