How are you restarting the level? This is happening because you disconnected the particles from the rocket and then it appears the rocket is just moved back to the start and the particles stopped. If you reload the scene like we do in the course it should all be reset again because everything is just reloaded. If you are just moving the rocket back to the starting platform and stopping the particles, you’d have to reconnect the particles to the rocket the way it was before, or move them to the new collision point before playing them.
Edit
I’m wrong. When you disconnect the particles using SetParent(null, false)
the particles are moved to (0,0,0) - or whatever the particle system’s local transform is set to. You should move them to the rocket just before playing them. You could use SetParent(null)
or SetParent(null, true)
but that would also affect the scale and rotation of the emitter
crashParticles.transform.SetParent(null, false);
crashParticles.transform.position = [rocket].transform.position; // <-- get the rocket's position
crashParticles.Play();
You need the rocket’s position. You can probably just pass it to StartCrashSequence
like this
default:
StartCrashSequence(other.transform.position);
break;
and update the method’s signature
void StartCrashSequence(Vector3 position)
{
// ... other code
crashParticles.transform.SetParent(null, false);
crashParticles.transform.position = position; // <-- get the rocket's position
crashParticles.Play();
// ... remaining code
}
Another Edit
We can get away without passing the position. Let’s disconnect the particles and keep their world stuff, then just rotate them to face up
void StartCrashSequence()
{
// ... other code
crashParticles.transform.SetParent(null, true); // <-- this is true now
crashParticles.transform.rotation = Quaternion.identity; // <-- reset the rotation
crashParticles.Play();
// ... remaining code
}
This will only work if the emitter’s original local rotation is (0,0,0)
Yet Another Edit
I didn’t realise that the CollisionDetector
is on the rocket. We already have the rocket position
void StartCrashSequence()
{
// ... other code
crashParticles.transform.SetParent(null, false);
crashParticles.transform.position = transform.position; // <-- set the rocket's position
crashParticles.Play();
// ... remaining code
}
This will do the trick. You may need to set the y to 0
var position = transfom.position;
position.y = 0; // set y to ground y - assume 0 for now
crashParticles.transform.position = position;