- Home /
How to make a particle system play on trigger with another box collider
Basically, the player runs into the coin. Both the coin and the player have a box collider. The particle system should play when the player hits the coins box collider.
Yet I don't know how to do this because the coins are attached to obstacles (prefabs) that randomly generate off the screen and eventually move on screen towards the player.
Here's what I have so far in the inspector, I've looked at tutorials all of which fail to give up to date advice. Any help is appreciated.
Answer by yayguy · Jan 04, 2019 at 01:19 AM
Is the coin collider's isTrigger set to true? If not set it to true, it should work. If yes, create a simple script to execute the ParticleSystem when the player hits the coin.
//declare your particle system here
void OnTriggerEnter (collider other)
{
ParticleSystem.Play()
}
If you need more help, feel free to add me on discord: pr0per #0369
Sorry I got busy yesterday I'll try your method and report back
Ok, so I declared a public particle system and inputted the coin particle system into the inspector. Here is the code
Now that I did that I'm getting an error saying particle system is not attached to a player yet my playscript is trying to reference it. I don't understand this because the player shouldn't need a particle system to activate the coins particle system?
When I attach a particle system to the player it works how it's supposed to, This isn't a lasting solution because the player can't have a particle system in my game.
Your answer
Follow this Question
Related Questions
Instantiated Object Not "Colliding" as Expected. 2 Answers
Child Object's collider setting off triggers 1 Answer
How do I prevent multiple triggers using OnTriggerEnter? 1 Answer
Call OnTriggerEnter with a trigger particle? 0 Answers
How can I get multiple objects with triggers, and standard collisions to work together? 2 Answers