Search Unity

Trigger video+audio play in JavaScript?

Discussion in 'Scripting' started by petervangurp, Jun 30, 2015.

  1. petervangurp

    petervangurp

    Joined:
    Jun 30, 2015
    Posts:
    1
    a
     
    Last edited: Mar 1, 2016
  2. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    You seem to have an understanding of GetComponent() if you wrote the code above. Therefore the answer should be simple:
    Code (JavaScript):
    1. OnTriggerEnter ()
    2. {
    3. GetComponent(AudioSource).Play();
    4. }
    If your Audio Source is on a different object, reference it:
    Code (JavaScript):
    1. var aud : AudioSource;
    2.  
    3. function OnTriggerEnter()
    4. {
    5. aud.Play();
    6. }
    Same goes for your moving texture.