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 JudyNails · Jul 05, 2010 at 07:44 PM · audioplayordersequenceconcat

How to string multiple audio clips together

Hi guys,

I need to string three audio clips together to give a score at the end of the game. For example, I've got a clip which says "You've got", several with a number - e.g. "two" and finally "stars!".

Obviously, the number audio clip is the player's score, stored as an int variable. Would any of you clever people be able to suggest how I can play each in turn so that it sounds like a sentence?

I've only been using Unity for a couple of weeks (and programming for as long!), so be gentle with me!

Many thanks

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
3
Best Answer

Answer by fherbst · Jul 05, 2010 at 08:15 PM

You can use something like this:

var startClip: AudioClip; // make sure to attach all your number audio clips here var numberClip:AudioClip[]; var endClip: AudioClip;

function PlayNumberSound(i : int) { audio.clip = startClip; audio.Play(); yield WaitForSeconds (audio.clip.length); audio.clip = numberClip[i - 1]; // i-1 because array starts at 0 audio.Play(); // you can probably leave this one out yield WaitForSeconds (audio.clip.length); audio.clip = endClip; audio.Play(); // you can probably leave this one out yield WaitForSeconds (audio.clip.length); audio.Stop(); }

function Start() { // Should play startClip + numberClip[5-1] + endClip PlayNumberSound(5); }

I haven't tested it, but it might work :).

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 JudyNails · Jul 08, 2010 at 08:36 PM 0
Share

Thank you Felix, you clever chap! I really appreciate this. It works perfectly (after I remembered to attach an audio source to the game object the script was attached to!). Now I need to work out some way of accessing the array based on the value of a string variable!

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

No one has followed this question yet.

Related Questions

AudioClip Import Order Randomized? 4 Answers

Audio clip not playing 1 Answer

How to upload a audio file.... 0 Answers

How do I use RayCasting to play a sound when my player is close to an enemy 1 Answer

Play a sound when i look at a certain object? 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