Hi all.
I’ve been working on a simple ballistic projectile class. part of this is creating impact fx when the projectiles hit their target. Pretty standard stuff i would think. The problem I’m having is that although the projectile (aka shot) is detected and destroyed upon entering a collider the object that represents the impactFX that are instantiated at the same time are not spawning in the same place, but rather further along the path of the shot. either inside or behind the object hit.
this image shows (red oval) the impact point of the show ( the white trails) and the (green oval) the spawn location of the fx
I thought at first it was because of the speed of the shot, but slowing them to near static only reduces the offset distance the fx is spawned. this is the method I’m using for this and it lives on the shot object.
public void OnTriggerEnter(Collider other)
{
if (other.tag != "Shot")
{
if (impactFX != null)
{
GameObject.Destroy(Instantiate(impactFX, transform.position, transform.rotation), 1f);
}
if (destroyOnImpact == true)
{
GameObject.Destroy(gameObject);
}
}
}
Anyone know why this happens and or how I can fix this please. Any help or pointers would be awesome. thanks.