Hi guys, I am trying to instantiate impact effect at the collision pointof particle effect. Example; I fire a particle effect and when it collides with anything, particle effect gets destroyed and impact effects gets instantiated at
the point of collision. This the script i wrote but it isn’t working. Can you help me ?
public void OnParticleCollision(GameObject other)
{
Instantiate(impactPrefab, other.transform.position, other.transform.rotation);
Destroy(gameObject);
}
This is not what i asked for. These documents are not helpful.
1 Like
Woah, that’s not answer for my reply…
1 Like
what you need to do is get the colliding objects position before you instantiate.
public Vector3 SpawnHere;
public void OnParticleCollision(GameObject other)
{
SpawnHere = new Vector3 (GameObject.transform.position)
Instantiate(impactPrefab, SpawnHere, other.transform.rotation);
Destroy(gameObject);
}
i didnt test that code so you might have to do it like this:
public void OnColliderEnter(Collider other)
{
SpawnHere = new Vector3(Collider.transform.position)
Instantiate(impactPrefab, SpawnHere, other.transform.rotation);
Destroy(gameObject);
}
ive never used particle collisions so… lol
1 Like