Problems with the jet particles

Hi, I´m having problems with the jet particles. The death and success are ok, but the jet aren display when I start the game. Any idea? Thanks

Hi Eduardo,

Welcome to our community! :slight_smile:

Are there any error messages in your Console?

No at all, here you can see my code:

using UnityEngine;
using UnityEngine.SceneManagement;

public class rocket : MonoBehaviour
{
// Control cohete
[SerializeField] float rcsThrust = 100f;
[SerializeField] float mainThrust = 100f;

//Sonidos cohete
[SerializeField] AudioClip mainEngine;
[SerializeField] AudioClip death;
[SerializeField] AudioClip sucess;

//Particulas cohete
[SerializeField] ParticleSystem mainEngineParticles;
[SerializeField] ParticleSystem deathParticles;
[SerializeField] ParticleSystem sucessParticles;


Rigidbody rigidBody;
AudioSource audioSource;
enum State { Alive, Dying, Transcending}
State state = State.Alive;


// Start is called before the first frame update
void Start()
{
    rigidBody = GetComponent<Rigidbody>();
    audioSource = GetComponent<AudioSource>();
}

// Update is called once per frame
void Update()
{
    if (state == State.Alive)
    {
        RespondToThrustInput();
        RespondToRotateInput();
    }
}

void OnCollisionEnter(Collision collision)
{
    if (state!= State.Alive) { return; }
   
    switch (collision.gameObject.tag)
    {
        case "Friendly":
            //Do nothing
            break;
        case "Finish":
            StartSucessSequence();
            break;
        default:
            StartDeathSequence();
            break;
    }
}
private void StartSucessSequence()
{
    state = State.Transcending;
    audioSource.Stop();
    audioSource.PlayOneShot(sucess);
    sucessParticles.Play();
    Invoke("LoadNextScene", 1f);
}
private void StartDeathSequence()
{
    state = State.Dying;
    audioSource.Stop();
    audioSource.PlayOneShot(death);
    deathParticles.Play();
    Invoke("LoadFirstLevel", 1f);
}

private void LoadNextScene()
{
    SceneManager.LoadScene(1);
}
private void LoadFirstLevel()
{
    SceneManager.LoadScene(0);
}

private void RespondToThrustInput()
{
    
    if (Input.GetKey(KeyCode.Space))
    {
        ApplyThrust();
    }
    else
    {
        audioSource.Stop();
        //mainEngineParticles.Stop();
    }
}

private void ApplyThrust()
{
    rigidBody.AddRelativeForce(Vector3.up * mainThrust);

    if (!audioSource.isPlaying)
    {
        audioSource.PlayOneShot(mainEngine);
    }

    mainEngineParticles.Play();

}

private void RespondToRotateInput()
{
    rigidBody.freezeRotation = true; // take manual control 

    float rotationThisFrame = rcsThrust * Time.deltaTime;

    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(Vector3.forward * rotationThisFrame);
    }
    else if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(-Vector3.forward * rotationThisFrame);
    }
    rigidBody.freezeRotation = false; //resume physics
}

}

Try this:

if (!mainEngineParticles.isPlaying)
{
    mainEngineParticles.Play();
}

Did this fix it?


See also:

No sorry, I put that line of code and still don´t work. I review the ship and there is everything in place correctly I think

Did you drag and drop the particle system from the Hierarchy into the Main Engine Particles field in the Inspector of the Rocket in the Hierarchy?

I belive you mean this
imagen

Yes, I meant those. Remove the particle systems from the Rocket component (see your second screenshot) and readd them.

Hi, I remove the partcile system but, later on don´t allow me to readd it from the rocket component I have to do from the assets. None of the partciles children related with the rocket can be added in that way I only can do it from assets. The strange thing is that only the rocket particles doesn´t work.

In this case, you will never see any particles in the scene because the particle systems in your Assets folder do not exist in the scene.

Do the children of the Rocket in your Hierarchy have got particle systems assigned to its children?

Do the children of the Rocket in your Hierarchy have got particle systems assigned to its children? Yes, imagen

But it is strange, because the death and sucess particles work in that way

Hi, I just solve it deleting all the elements and then it allow me to do has you say before from the child. Thanks for your help.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms