Hey there, just a small problem I am having raycasting in Unity. I want to play a video after clicking a gameObject tagged “PlayButton1” which when clicked will play/pause the video. I have the code almost working, in that, if I add a semi colon after the hit.transform.tag line it will play/pause the video, but when clicked anywhere, not clicking on the specific object I want.
Really can’t figure this out and don’t know ehere to go from here. Thanks in advance!
var movTexture : MovieTexture;
function Update () {
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray, hit, 100))
{
if (hit.collider.tag == "PlayButton1")
{
if (movTexture.isPlaying) {
movTexture.Pause();
}
else {
movTexture.Play();
}
}
}
}
}