Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

noob question help needed animation with sound

Discussion in 'Animation' started by Khofnak, Apr 24, 2016.

  1. Khofnak

    Khofnak

    Joined:
    Mar 3, 2015
    Posts:
    21
    upload_2016-4-24_18-1-40.png

    how can i play sound at between different state of animation using mechanim or anymethod will bw appreciated
     
  2. CharactersArt

    CharactersArt

    Joined:
    Dec 23, 2015
    Posts:
    37
    Hi.
    You can use Animation Events.

    1. Create Script and add it to the animated object.

    EventScript.js

    #pragma strict
    function Start () {
    }
    function Update () {
    }
    function PlayMyAudio(audio:AudioClip){

    GetComponent.<AudioSource>().clip=audio;
    GetComponent.<AudioSource>().Play();
    GetComponent.<AudioSource>().time=42; //play starting from 42 seconds
    }

    2. Create an Event in the needed frame of the needed animation by right-click mouse.

    scr2.png

    3. Set Event function and parameter (audio clip).

    scr3.png

    That's all.
     
    Last edited: Apr 24, 2016
    burnsky and Khofnak like this.
  3. Khofnak

    Khofnak

    Joined:
    Mar 3, 2015
    Posts:
    21
    sir you are LOve
     
  4. burnsky

    burnsky

    Joined:
    Mar 16, 2019
    Posts:
    3
    Five years later, this reply is still GOLD. Thanks!
     
    dcomptonambrose likes this.