Question by
grassy756_unity · Feb 25, 2021 at 12:11 PM ·
instantiateparticlesysteminstantiate prefab
Instantiated object not in right position
I'm making an FPS game and when an enemy dies I want there to be a particle explosion so I made a particle system get Instantiated when an enemy dies. However the particle system works for some enemies but for other enemies, the particle explosion is in the floor?
public int hitPoints = 100;
public Transform deadVFX;
public Transform deadPoint;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag.Equals("Bullet"))
{
hitPoints -= 50;
}
if (hitPoints <= 0)
{
Instantiate(deadVFX, deadPoint.transform.position, deadPoint.transform.rotation);
Destroy(gameObject);
}
}
Here's my code, deadPoint is an empty GameObject where I want the explosion to be, and deadVFX is the particle system prefab. (This script is attached to the enemy so it instantiates the explosion them destroys the enemy object)
Comment
Best Answer
Answer by grassy756_unity · Feb 25, 2021 at 12:19 PM
Actually turns out I fixed this myself, my enemy had a rigidbody which its not supposed to have, and that was messing it up. (Also fixed some other problems I was having)