• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Waldy · Feb 12, 2013 at 11:20 AM · particle systemkeyholdingplays

How do you activate a particle system while holding a key and how to activate audio holding a key?

I am designing a space game with a friend and would like to know how would you about of making a script which makes it when i hold "z" (When the spaceship moves forward) audio plays and how do i make a particle system activate when i hold "z" as well

  • note i want the sound and particle system to stop on release of the key e.g. hold "z" engine sound effect plays and particle system on the engine starts then they both stop when i release "z"

Thanks :D

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Chronos-L · Feb 13, 2013 at 07:39 AM

An example script (you will have to fill in the details):

 /*You need to set the emit of this particle system to 0 at the editor,
 so it will not emit at all during play-mode by itself*/

 public ParticleSystem thruster; 

 /* The audio, I am not sure about this one as I have little experience 
 with audio (but you can google on how to play audio in unity*/

 public AudioSource audio;
 
 void Update() {
 
    if( Input.GetKey( KeyCode.Z) ) {
       thruster.Emit(10); //Emit some particle
       audio.Play();
    }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Displaying GUI question? 1 Answer

Command for Holding a Key Down & Shift Key 2 Answers

Holding down 'M' for map? 1 Answer

ParticleSystem TriggerModule: Collide with world / collide with unlimited colliders? 0 Answers

Need Help with ShaderGraph, VFX, Particle Effect 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges