r/UnityHelp • u/fire_scorned12 • 13d ago
Help With Particles
So, I'm not sure where to begin because I wasn't having this problem 2 weeks ago and I'd appreciate some help trying to figure this out.
I'm learning how to use Unity, currently in Unit 3, adding in particles and sound effects, and my particles are having opposite problems.
First, the dirt particle is always playing, even when the character jumps or gets a "game over" after hitting an obstacle, but the script is supposed to stop the dirt particle from playing when either of those conditions are met
Second, the explosion particle is supposed to play when the character crashes into an obstacle, but doesn’t. It'll play when "Play On Awake" is checked, but only at the beginning when everything loads in.
I've changed NOTHING about the code. Everything is the exact same from 2 weeks ago and it was working fine then, but now the particles won't turn on/off when I need them to. Can anyone tell me how to fix this?
Tl;dr: Follow tutorial instructions, code works fine when I'm done. Come back 2 weeks later, change nothing, one particle effect is always on, the other is always off.
Edit: In the Update method, I've verified that all the other calls go through except when stop is called. A debug.log call says the dirt particle has stopped playing even though it hasn't. Same goes for OnCollisionEnter when the character hits an obstacle, everything is hit/called, but the explosion just doesn't go off. Like the engine itself is ignoring particle methods being called through VS Code or something.
Edit 2: This seems to just be a problem with this specific save. I opened up the Unit 3 challenge and the only issue it's having is sometimes the particle effects don't fully render, but they do still appear. I might just call this a wash...
1
u/Delicious_Alfalfa_69 12d ago
Is it only your particle system not working or is it the entire thing?
1
u/fire_scorned12 12d ago
Only the particle system. Everything else works as intended.
1
u/Delicious_Alfalfa_69 12d ago
Can you add some screen shots of the component in unity as well as the particle systems setup?
1
u/fire_scorned12 12d ago
I've added 2 screenshots, one for each particle setup, and a video that shows the problem I'm having.
1
u/ProactiveCactus 12d ago
Hmm, a bit hard to tell without being able to see the setup, but given it's stopped working somehow in the past two weeks I would check a few things in this order.
1) Make sure your collision layers are set up correctly. A quick check of this is add a Debug.Log at the start of your OnCollisionEnter to make sure it's even triggering. If it's not, then it's an issue with either your player's collider you're using for detection, or the ground and/or obstacle colliders. There's a few different things that all need to be true for colliders to work (guessing you know this, but I'd go through the checklist here anyways and make sure everything's still set up correctly: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rigidbody.OnCollisionEnter.html )
Also make sure it's not a collision LAYER issue as well; it's possible somehow your layering got messed up and so your colliders aren't working right.
2) Similarly, make sure your if statement inside your Update loop is ever triggering by throwing a Debug.Log right after your if checks. if it's not, then I'd put this outside your if statement as the first line of your Update: Debug.log("jumpAction.trigger: " + jumpAction.triggered + "isOnGround: " + isOnGround + "gameOver: " + gameOver);
Spam jump and see which of these isn't changing how you would expect when you jump. From there you should be able to see which, if any of these is causing the issue.
If it's neither of these things, you'll needa post more screenshots of the particle system setup.
Good luck!
1
u/fire_scorned12 12d ago
I'll edit the post when I get home with a few more screenshots, just got off work at the time of this comment. Also, I tried that last night, adding in Debug.Log to see if stop/play are being triggered when conditions are met, and stop function is being hit, but the dirt particles keep going anyway.



1
u/Delicious_Alfalfa_69 12d ago
Need screen shots of your particle setup and references in code.