0
\$\begingroup\$

I made a simple spaceship that has a particlesystem. When I press "space" button, spaceship should fly and particle system should instantiate and play. But it's not playing. It seems in hierarchy as clone but not playing.

As you see, particle effect is instantiating but not playing. It should play at bottom of spaceship

Those are codes

void FlyShip()
{


    if (Input.GetKey(KeyCode.Space))
    {

        rb.AddForce(Vector3.up * jumpForce);


        if (!takeoffSound.isPlaying)
        {

            // _rocketJetParticle is gameobject. 
            _rocketJetParticle = Instantiate(rocketJetParticle, new Vector3(transform.position.x, transform.position.y - 4, transform.position.z), transform.rotation);
            takeoffSound.Play();

        }

    }

    else 
    {
        //Destroy(_rocketJetParticle);
        takeoffSound.Stop();
        
    }


}
\$\endgroup\$
3
  • \$\begingroup\$ Did you mean to tick the "Play on Awake" checkbox, if not manually starting the particle system via script? \$\endgroup\$ Commented Feb 21, 2021 at 21:26
  • \$\begingroup\$ I wanted to play particle system when I instantiate gameobject. But It wasn't playing. I found the solution. If you don't tick "Play on Awake" , the particle system attached to gameobject doesn't work. I didn't know that. @DMGregory \$\endgroup\$ Commented Feb 22, 2021 at 15:37
  • \$\begingroup\$ Want to share your solution as an Answer below? \$\endgroup\$ Commented Feb 22, 2021 at 16:15

1 Answer 1

1
\$\begingroup\$

I found the solution.

If you instantiate a particle effect and want it to play when it instantiate you should tick "Play on Awake" box

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.