I’m programming some kind of 2D-platformer and when a projectile (GameObject) hits an barrier I want to initialize and rotate a ParticleSystem to the Colission-Normal. This ParticleSystem simulates some kind of shrapnels and dust that should fly in the opposite direction of the projectile.
This is my code so far:
private void ApplyHitEffect(Health.HealthChangedDetails details)
{
if (HitDamageEffect == null)
return;
GameObject obj = (GameObject)Instantiate(HitDamageEffect.gameObject, transform.position, Quaternion.identity);
Vector3? impactVector = details.GetImpactVector();
if (impactVector != null)
{
Debug.Log("rotate particle system");
//obj.transform.LookAt(impactVector.Value);
obj.transform.rotation *= Quaternion.FromToRotation(obj.transform.position, impactVector.Value);
}
Destroy(obj, HitDamageEffect.DestroyTime);
}
The code rotates the Particlesystem but not in the opposite direction of the projectile.
Any help on how to accomplish that is really appreciated.