Explosio Partlcles play in beginning

Hello;
I’ve just made the lecture “Enable A Gameobject From C#” and reviewed the code a lot of time, and and its all correct according to the lecture. The play scene and loadlaveldelay is working perfectly, but in my project the explosion particle effect play only on awake, on the beginning of the scene not on the collisions, I’m using Unity 2018.3. If somebody could help saying what I did wrong I’ll be very thankful.

Hi Breno,

Without seeing your code, it’s impossible to tell you what might have gone wrong. If Play On Awake does not work, you could call the Play() method in your code.


There’s the code. I put some names in Portuguese because I’m Brasilian. Bus the structure is the same of the lecture

Did you enable “Loop” in your Particle System?

Your LevelLoadDelay seems to be very short, just 1 seconds. Try to increase the value to give your ParticleSystem some time to play.


Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:


See also;

Well, I didn’t enabled “loop” in particle system.
What happens is that the explosion particles (GameObject MorteFX) play when start the scene and not when collides.
As told before I’m using Unity 2018.3.0f2
There’s the following error message on console:
“Assets\colisionManager.cs(9,56): warning CS0649: Field ‘colisionManager.MorteFX’ is never assigned to, and will always have its default value null”
The code is pasted below.
Thanks

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class colisionManager : MonoBehaviour
{
[Tooltip (“In seconds”)][SerializeField] float LevelLoadDelay = 1f;
[Tooltip(“FX Prefab”)] [SerializeField] GameObject MorteFX;

private void OnTriggerEnter(Collider other)
{
    SequenciaMorte();
    MorteFX.SetActive(true);
    Invoke("ReloadScene", LevelLoadDelay);
}

void SequenciaMorte()
{
    print("Morreu");
    SendMessage("StartMorte");
}
private void ReloadScene()
{
    SceneManager.LoadScene(1);
}

}

Increase your LevelLoadDelay in your Inspector. For testing purposes, set it to 10. Furthermore, call MorteFX.Play() once you set the MorteFX game object to active.

There’s the following error message on console

Try the following: [Tooltip(“FX Prefab”)] [SerializeField] GameObject MorteFX = default;.
If default does not work, test null.

This topic was automatically closed after 14 days. New replies are no longer allowed.

Privacy & Terms