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 christianmanners · Dec 13, 2013 at 05:35 PM · soundzombiezombiesglobal script

how is it possible to make a sound based spawning system?

I am at the early stages of making a zombie game and I've been trying to make a zombie spawner that activates upon certain sounds (e.g. running sound, shooting shouts, etc) but i have no idea how to make this (im still new to coding) I AM NOT ASKING FOR THE SCRIPT TO BE MADE FOR ME... I WANT TO MAKE MY OWN but i have now idea how to right and what is used to make things in unity activate when certain sounds are made... how would i go about writing this and what is used in the script to make things triggered by sounds?

Comment
Add comment · Show 5
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 guitarxe · Dec 13, 2013 at 05:43 PM 1
Share

Uhm, well, if you start on your game and get more aquainted with Unity and your scripting language of choice, I am sure you will eventually figure out a solution of your own.

If I was trying something like this, my first attempt would be to call events when certain sound clips are played by the player (like you say, shooting, running, etc), and then have my spawner object listen for these events and then do whatever logic to decide whether to spawn enemies or not, and where.

avatar image christianmanners · Dec 13, 2013 at 05:48 PM 0
Share

i have been making the game for a while but I've only just started with this... before the spawner is just the ordinary spawning 1 zombie per X seconds but now i want to change it to make it more like this... I've done some scripting but nothing like this before... i like you're idea... but what would i write to have the spawner listen to these sounds?

avatar image OP_toss · Dec 13, 2013 at 06:02 PM 1
Share

Take a look at documentation for events. Basically you define an event in the sound script, += a method to it in the spawner script, and call the event when the event should be triggered. It will call all methods added to it.

http://msdn.microsoft.com/en-us/library/edzehd2t(v=vs.110).aspx

avatar image guitarxe · Dec 13, 2013 at 06:05 PM 1
Share

Take a look at how the event system works in C# (if you are using JS, I can't help with that, sorry, but pretty sure you can find that information on your own).

http://unity3d.com/learn/tutorials/modules/intermediate/scripting/events

http://answers.unity3d.com/questions/593012/how-to-pass-on-information-through-c-events.html

Once you figure out how to use events, it will become evident where to go from there :)

avatar image christianmanners · Dec 13, 2013 at 06:13 PM 0
Share

thank u guys i'll give this a shot and see what i can get from it :D

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Kumo-Kairo · Dec 13, 2013 at 06:15 PM

The point is - your sounds will be triggered by your scripts. So instead of triggering something BY sound you will trigger something SIMULTANEOUSLY WITH triggering your sound. It will be easier to implement and much easier to understand. There's no point of making these simple things so complicated

Scenario: Your player starts walking. You know that if he walks he produces step sounds. So you trigger these sound and in the exact same time, you trigger something related with this event. Same thing with shouting - you trigger shout sound AND something else on the moment you press your "SHOUT" button.

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.

Follow this Question

Answers Answers and Comments

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How can I play audio while a non player controlled object is moving and stops playing when object stands still? 1 Answer

Sprinting Audio Problem 1 Answer

Script Error 1 Answer

Trigger sound when pressing button 2 Answers


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