Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by AtmosDesigns · Jun 17, 2014 at 10:51 PM · particlessound

Randomizing sounds (on keypress)?

hey everyone, im working on a game where you can "burp" by pressing the b key in game, i got a little bored with hearing the same sound over and over so i made another sound, and a script that let it have 2 sounds, but from here i have no idea how i could "randomize" the order of these sounds and also how i could add more sounds (below is my script)

 var canPlayAudio = true;
 var waitTime = 1.0;
 var whichBurp : boolean = true;
  
 var Burp1 : AudioClip;
 var Burp2 : AudioClip; //Drag your audio clip here in the Inspector.
  
 function Update () 
 {
 AudioController();
 }
  
  
 function AudioController()
 {
 if (Input.GetKeyDown ("b") && canPlayAudio && whichBurp)
     {
     canPlayAudio = false;
     audio.PlayOneShot(Burp1);
     yield WaitForSeconds(waitTime);
     whichBurp = false;
     canPlayAudio = true;
     }else
    if (Input.GetKeyDown ("b") && canPlayAudio && whichBurp == false)
     {
     canPlayAudio = false;
     audio.PlayOneShot(Burp2);
     yield WaitForSeconds(waitTime);
     whichBurp = true;
     canPlayAudio = true;
 }
 }

Also, on a different topic, how would i make a particle system for what appears to be a stream of "vomit"? Thank you guys alot, atmos :)

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

Answer by Jeff-Kesselman · Jun 17, 2014 at 10:55 PM

Put your burps in an Array and use Random.Range to select one http://docs.unity3d.com/ScriptReference/Random.Range.html

You already have the answer on your vomit, you need to create a particle system. One that ejects sideways and has a pretty fair gravitational pull down.

You use the http://docs.unity3d.com/Manual/class-ParticleSystem.html inspector to edit your particle system. If you have never done particle system before you might want to start here: https://www.youtube.com/watch?v=xnK5g2z9ESQ

Comment
Add comment · Show 1 · 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
avatar image AtmosDesigns · Jun 18, 2014 at 08:32 AM 0
Share

Thanks man, i tried mucking around with particles but it just plain doesnt look good, any more tips? THAN$$anonymous$$S a heap anyways!

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Play sound from particle 1 Answer

Detect the start of a particle burst emission 0 Answers

Sound play in spot of particle collision 1 Answer

Space Shooter Player Will Not Instantiate an Explosion After Getting Killed 4 Answers

Add audio clip to a specific audio source 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges