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 dans13 · Jan 10, 2015 at 01:11 PM · audioaudioclipdelaysync

Audio sync with explosions

I was following one of the live training PIT: Cinematic and trying to figure out how to get the explosion audio to sync with the script. There is a 3 sec delay from when character starts walking until the explosion(visual) but the explosion(audio) plays as soon as "play" button is pressed. I have tried putting the listener on the car, the character and the camera. I have tried switching play on awake to on and off. In the off position, no sound is played. Not too familiar with scripting but I tried adding a pub var to a script that instantiates and regulates(time delay scale) the explosion but I am not getting anywhere. Here is the script:

using UnityEngine; using System.Collections;

public class ExplosionCar : MonoBehaviour {

 public GameObject explosion;
 public AudioClip nukeIt;


 // Use this for initialization
 void Start () {
     Invoke ("explode", 3f);
     Invoke ("nuke", 3f);
 }
 

 void explode(){
     Instantiate (explosion, transform.position, Quaternion.identity);
     Destroy (this.gameObject);
 }

 void nuke(){
     //not sure what I need to put in here. Have tried 
     audio (AudioClip.nukeIt);
Comment
Add comment · Show 1
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 dans13 · Jan 10, 2015 at 11:57 AM 0
Share

Ok, so I changed the code in the script. Got rid of the nuke function and the nukeIt var. Did some research and now I have this:

using UnityEngine; using System.Collections;

[RequireComponent(typeof(AudioSource))] public class ExplosionCar : $$anonymous$$onoBehaviour {

 public GameObject explosion;



 // Use this for initialization
 void Start () {
     Invoke ("explode", 3f);
     audio.Play();
     audio.PlayDelayed(5f);
 }
 

 void explode(){
     Instantiate (explosion, transform.position, Quaternion.identity);
     Destroy (this.gameObject);
 }

}

Only problem now is volume is too low. I have checked it in the inspector and even tried making sure it was set to 1 in the script, to no avail. Still not sure what the problem is.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hypnoticmeteor · Jan 10, 2015 at 01:27 PM

If you think that you have done everything to increase the audio and it did not become high.

  1. Audio Source is very far from the listener.(Add an audio source to the main camera and play the sound there)

  2. The audio was recorded at a low volume.

    //play audio on main camera generally where Audio Listener is present

      Camera.main.audio.playOneShot(nukeIt)
    
    
    
    
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 dans13 · Jan 11, 2015 at 06:20 AM 0
Share

I figured out the volume problem part of it. I "fiddled" with a few things and realized that the audio source was a 3D sound clip. DUH! Changed it to 2D and fixed that problem. As far as the ti$$anonymous$$g is concerned, I think it might be a latency issue. I am using the on-board sound processor and I am guessing this might be what is wrong. I have a card installed but I don't use it to save on processing power of my computer. Will try it and see if that fixes it. Thanks for all the help.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

AudioClip Precise Timing and Delay 1 Answer

Audio loop after time 2 Answers

audio.clip.GetData() returns no data. 0 Answers

Keep playing audio on android even if screen dim or sleep 0 Answers

Stopping audio source without stopping oneshot clips 0 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