Particle problem

hi, I have a problem with my “WIN” particule. The particule doesn’t want to work when the game object hits the “win” platform.

the particule code:

switch (collision.gameObject.tag)
{
    case "DANGER!":
        Situation = PlayerSituation.Died;
        Thrust.Stop();
        Fail.Emit(10000);
        AS.Stop(); 
        AS.PlayOneShot(Explosion);
        break;

    case "WIN": 
        Win.Play(); // activation of the win particule.//
        break;
}

ps: I put the debug.log() and nothing happened in the inspector and I add the “WIN” tag.

Hi,

Three potential issues come to my mind:

  1. The “Win” platform does not have the “Win” tag assigned, or the “Win” tag has a typo like "Win ".

  2. The collision method does not work. Maybe there is a typo or the game objects don’t have a collider attached.

  3. The Win variable does not have a ParticleSystem assigned or it has a prefab assigned instead of a ParticleSystem from the Hierarchy.

Where exactly did you use Debug.Log?

i try all the potential issues and i make any of these mistakes

Are there any error messages in your console?

hi Nina,
the problem is getting worst, i try to remove my rocket and to make a new one, but now i have a new problem, my new rocket doesn’t want to move. I add a script ,a rigidbody. I put a mass: 0.05.Can you help with this one and after that help with the other

I would say let’s solve the problem with the rocket first because the particle system is just decoration.

There was a bug in Unity that prevented the rocket from flying when it was selected in the Hierarchy while playing. Make sure you did not select it. Does it fly?

If not, it might be an issue with your code. If you exposed fields in the Inspector, those fields override the values in your script. Check if the values in your Console are not 0 unless there is a good reason for that.

First, i see if i don’t selected the rocket in the hierarchy while the game was playing and the problem still here even i deselected the rocket. So i will send all my code

code :

using UnityEngine;

public class ROCKET : MonoBehaviour
{
    AudioSource AS;
    AudioClip AC;
    Rigidbody RB;

    public AudioClip Explosion;

    public float RotationThrust = 1000f;
    public float UpThrust = 1000f;

    public ParticleSystem Thrust;
    public ParticleSystem Fail;
    public ParticleSystem Win;

   enum PlayerSituation {Alive,Died,Win };

    PlayerSituation Situation;

    void Start()
    {   
        RB = GetComponent<Rigidbody>();
        AS = GetComponent<AudioSource>();  
    }

    // Update is called once per frame
    void Update()  // action qui doit se faire chaque secondes//
    {
        if (Situation == PlayerSituation.Alive)
        {
            Up();
            Rotate();
        }
    } 

    private void OnCollisionEnter(Collision collision)
    {
        if (Situation!=PlayerSituation.Alive)
        {
            return;   // remove the other collision after the death//not for the rocket 
        }

        switch (collision.gameObject.tag)
        {
            case "DANGER!":
                 Situation = PlayerSituation.Died;
                 Thrust.Stop();
                 Fail.Emit(10000);
                 AS.Stop();                 
                 AS.PlayOneShot(Explosion);
                 break;
            case "WIN":
                Debug.Log(collision.gameObject.tag);
                Win.Play();
                break;
        }
    }

    void Up()     // propulsion of rocket//
    {
        float upPlus = UpThrust * Time.deltaTime;    // add more propulsion//  

        if (Input.GetKey(KeyCode.W)) // my rocket doesn't want to work ---> maybe this is the problem
        {
            RB.AddRelativeForce(Vector3.up * upPlus);

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

            Thrust.Play();
        }
        
        else
        {
            Thrust.Stop();
            AS.Stop();
        }
    }

    void Rotate()   //rotation of the rocket//
    {
        float rotationPlus = RotationThrust * Time.deltaTime;
        RB.freezeRotation = true;

        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(transform.forward * rotationPlus);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(-transform.forward * rotationPlus);
        }

        RB.freezeRotation = false;
    }
 }

Thank you. Next time, please format your code until it looks readable and nice. I edited your post for you this time.

Your Up method is wrapped in an if statement. Check with a Debug.Log whether (Situation == PlayerSituation.Alive) is true. If it is false, the if block will not get executed.

Check the value of upPlus.

Ok i put the Debug.log() in the Start method and the game answer “True”, so i think there is any problem with my enums.

Hi Nina, my fly problem is solved, now we can aim the particle problem, so i use the debug.log with all my particle and all of them is working, so the problem is not in my code, so where is my problem if he is not in my code.

ps: i checked the particle system course twice and i don’t find the problem.

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

Privacy & Terms