- Home /
c# play particle effect on key press?
i'm wondering how to play a particle effect on key press
this is what i'm have but i don't want to use animation
if(Input.GetKeyUp(KeyCode.Alpha1)) {
animation.CrossFade ("1h_attack1");
Use a particle system with particleEmitter.Emit(); code on keypress.Look here for particle ref
http://docs.unity3d.com/Documentation/ScriptReference/ParticleEmitter.Emit.html
ive got the code in but i get this error after i try to use the attack
$$anonymous$$issingComponentException: There is no 'ParticleEmitter' attached to the "$$anonymous$$uscular" game object, but a script is trying to access it. You probably need to add a ParticleEmitter to the game object "$$anonymous$$uscular". Or your script needs to check if the component is attached before using it. UnityEngine.ParticleEmitter.Emit (Vector3 pos, Vector3 velocity, Single size, Single energy, Color color) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/Editor/Graphics.cs:2605) PlayerAttack1.Update () (at Assets/_Scripts/random scripts/PlayerAttack1.cs:39)
if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.Alpha1)) { particleEmitter.Emit(Vector3.zero, Vector3.up, 0.2f, 2, Color.yellow);
Answer by $$anonymous$$ · Oct 07, 2013 at 11:16 AM
You can either try DjSpun's solution or you can instantiate and destroy on events like press button.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
how can i auto target Gameobject on startup 1 Answer
c# how to make a simple quest? 1 Answer