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 Bensirpent07 · Feb 09, 2014 at 11:19 PM · audio

Audio Problem

I am trying to play a audio when an object is destroyed the only problem with that is when I click "Play on Active" It just keeps playing every time the object is spawned. One way I was able to fix this was through turning off "Is Trigger". But when I do that the object just floats away. I do have tumble on it. I do not know if the code or something for it is messed up but here are all the scripts I have attached to it.

Random Rotator

 using UnityEngine;
 using System.Collections;
 
 public class RandomRotator : MonoBehaviour 
 {
     public float tumble;
 
     void Start ()
     {
         rigidbody.angularVelocity = Random.insideUnitSphere * tumble;
     }
 }


Destroy By Contact

 using UnityEngine;
 using System.Collections;
 
 public class DestroyByContact : MonoBehaviour 
 {
     public GameObject explosion;
     public GameObject playerExplosion;
 
     void OnTriggerEnter(Collider other) {
         if (other.tag == "Boundary") {
             return;
         }
         Destroy (other.gameObject);
         Destroy (gameObject);
         Instantiate (explosion, transform.position, transform.rotation);
             if (other.tag == "Player") {
                 Instantiate (playerExplosion, other.transform.position, other.transform.rotation);
             }
     }
 }


Mover

 using UnityEngine;
 using System.Collections;
 
 public class Mover : MonoBehaviour
 {
     public float speed;
     
     void Start ()
     {
         rigidbody.velocity = transform.forward * speed;
     }
 }
Comment
Add comment · Show 2
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 MaGuSware™ · Feb 09, 2014 at 11:57 PM 0
Share

Going to need a little more info.

Firstly, it keeps playing when what object is spawned?

When you say keep playing, do you mean like looped?

Does the explosion object have the loop flagged on the audio source and does the explosion destroy itself when it is done?

avatar image Bensirpent07 · Feb 10, 2014 at 01:14 AM 0
Share
  1. Every time a asteroid is spawned it makes the sound like it is being destroyed but it doesn't actually get destroyed.

  2. No not a loop, just a sound every time it is spawned.

  3. It is not flagged.

0 Replies

· Add your reply
  • Sort: 

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

Why my sound it's not attaching to my Flashlight 2 Answers

one shot Sound on collision. Unity 4.0 problem. 2 Answers

Audio Script doesn't work 0 Answers

Global Varible Problem 2 Answers

Using High Pass Filter with script 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