- Home /
how to play movie only when it been trigger
hello, i want my movie to play only when it been triggered by the player. i use box as my trigger object. when the player hit the box, canvas will appear and on the canvas i add raw image as my movie texture. can someone check the coding for me. thank you
using UnityEngine; using System.Collections; using UnityEngine.UI;
[RequireComponent(typeof(AudioSource))]
public class simpang4Movie : MonoBehaviour {
public MovieTexture movie;
private AudioSource audio;
// Use this for initialization
void Start () {
GetComponent<RawImage> ().texture = movie as MovieTexture;
audio = GetComponent<AudioSource> ();
audio.clip = movie.audioClip;
movie.Play ();
audio.Play ();
}
//void onTriggerEnter(Collider col) {
//if(col.CompareTag("Player"))
// movie.Play ();
// audio.Play ();
//}
//}
// Update is called once per frame
}
Comment
change the syntax of onTriggerEnter to OnTriggerEnter
OnTriggerEnter
Your answer
Follow this Question
Related Questions
Reaction game?? 0 Answers
Can't click gameobject when over another trigger? 1 Answer
call/trigger animation of other object 2 Answers
Player Falls Through Floor on Trigger 1 Answer
Increase Speed 1 Answer