Particle System Play On Player trigger?
I have no complete knowledge and understanding of code BUT I am slowly picking it up.
Here's the problem:
I have a roll-a-ball game, where I'd like to trigger a particle system when the player picks up a gem. I have the particle system attached to the gem game objects and not as a child (could be the problem) I do have a collider on the player and an OnTrigger for the gems. My pick up item script works I just don't know what I could add to help?
I'm usually happy searching forums, YouTube or just trying to have a go but apparently a new particle system and no exact answers for my issue, I would really appreciate some help. :)
Whenever you get a callback message from OnTriggerEnter, just stop and (re)play your particle system gameobject. In your case, it is preferable to set the simulation space of your particle system to “world” if it’s “local”.
Answer by CannyRhymez · Oct 16, 2018 at 11:42 AM
Thank you so basically as I go through the gem, I add a stop THEN play? How would I do that? I’ve had a look through the particle system section in scripting api, I have found particle system.play but it didn’t work right for me. Wondering if there was a specific line of code I had to use to instanciate the particles? I will change them from local to world as I’m pretty sure once the gem deletes the particles will too right? Really appreciate the help and advice :)
In Start(), Awake() or OnEnable(), you instantiate your particle fx prefab to a clone (Transform) variable, then GetComponent of ParticleSystem (PS) from this clone to a PS var.
In Update(), whenever you need to play the fx, “stop” the previously played PS clone, move the Transform clone position to the new location, then “play” the PS clone.
Your answer
Follow this Question
Related Questions
Toggle particles on trigger enter depending on physic material 0 Answers
Can the new ParticleSystem Trigger Module access the particle's collision collider? 0 Answers
Importing a blender mesh for a particle emitter. 3 Answers
optimize thousands of sprite prefab 0 Answers
How do you use emission.rate? 2 Answers