Home > Enterprise >  Particle effect on collision?
Particle effect on collision?

Time:12-07

This is a simple question. I did it a couple of times already, don't know why I can't get it done now... I made a particle effect, I want this to get played when the player collides with the platform. Here's what I've done:

public class StartingPlatformFall : MonoBehaviour
{
    //public GameObject smoke;
    //public GameObject spawn;
    public ParticleSystem smoke;

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            //Instantiate(smoke, spawn.transform, Quaternion.identity);
            smoke.Play();
        }
    }
}

What am I doing wrong?

CodePudding user response:

The smoke particle effect will be playing somewhere else. After the collision, get the position of the player and instantiate the particle prefab over there.

Instantiate(smoke prefab, player  position, player rotation);
particle.play();
  • Related