Question by
Wingmann · Jul 12, 2017 at 05:00 AM ·
transformparticlesystemtransform.positionimpact
Instantiating gameobject creates it at second impact point
Hello guys, sorry for the butchered title. In my project I have a projectile fired from an irrelevant gameobject. When this projectile impacts a surface, it creates a particlesystem and deletes itself. However, when it impacts a surface, it creates the particlesystem at the last projectile's impact point, rather than it's current one. Here is my code:
public GameObject impact;
void Start () {
impact = Resources.Load("ProjectileImpact") as GameObject;
}
void OnCollisionEnter(Collision other)
{
GameObject impactSystem = Instantiate(impact) as GameObject;
impact.transform.position = this.transform.position;
Destroy(this.gameObject);
}
What's causing it to use the previous impact point? Am I missing something?
Edit: This also persists over different editor game sessions, EG the particle effect will appear at the last projectile from the previous session.
Comment