Hi guys, I have a problem.
The game i’m making has a points system that’s increased whenever the player picks up a coin. These coins have particle effects when they are picked up and this also destroys the coin.
Only problem is that these particle effects are starting when the level loads which isn’t what i want. If anyone can help, that would be great
#pragma strict
var coinparticles : Transform;
function OnTriggerEnter (info : Collider)
{
if (info.tag == "gPlayer")
{
Debug.Log("Add coin counter here!");
var effect = Instantiate(coinparticles, transform.position, transform.rotation);
Destroy(effect.gameObject, 3);
Destroy(gameObject);
}
}
“gPlayer” is the player tag used for collision handling as i’m planning to implement multiplayer later on.
“coinparticles” is the name given to the particle effect
1 Like
What type of particle component are you using? If you’re using the regular Particle System then go into unity, and click on your coin prefab. If the Particle System component doesn’t show up in the inspector, then drag the coin into your scene and select that one… In the main settings of the Particle System look for the “Play On Awake” checkbox and uncheck it. Then just update your existing prefab with the new one.
(Red Square - You obviously want it UN-checked lol forgot to uncheck it :P)
If you’re using an Ellipsoid Particle Emitter with a Particle Animator and all that good stuff, then just uncheck the Emit box in the Inspector, and call ParticleEmitterName.Emit();
in your OnTriggerEnter. I hope that all makes sense I wrote with the assumption you know what I’m talking about lol, if you need more help with it feel free to PM me.
9 Likes