play MovieTexture only for viewer

Options
Hello everyone.

I am having trouble trying to solve this problem:
I have network players walking up to kiosks. The Kiosks automatically play videos (ontriggerenter) and stop (ontriggerexit).
The problem is that all players hear and render the videos, not just the player who triggered it.

I added If View is mine, but that confused things by only letting one of the players view the videos, locking out access right to the other players.
I would appreciate any help (I am from NZ, so excuse me if my replies seem late).

This is my current code (as you can proberbly tell, I am new), cheers:

[code2=csharp]using UnityEngine;
using System.Collections;
using ExitGames.Client.Photon;
[RequireComponent(typeof(PhotonView))]
public class VideoPlayer : Photon.MonoBehaviour {

public bool playtoggle = false;

void Update(){
Renderer r = GetComponent<Renderer>();
AudioSource audio = GetComponent<AudioSource>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;

if (Input.GetKey(KeyCode.P))
{
if (playtoggle == true)
{

audio.Pause();
movie.Pause();
playtoggle = false;
print("pause");


}

else
{
audio.Play();
movie.Play();
playtoggle = true;
print("play");
}
}


}






void StopVideo(){
print("stop");
Renderer r = GetComponent<Renderer>();
AudioSource audio = GetComponent<AudioSource>();
MovieTexture movie = (MovieTexture)r.material.mainTexture;
audio.Stop();
movie.Stop();
}


void OnTriggerEnter(Collider other){
Debug.Log ("Enter");
PhotonView pv = PhotonView.Get(this);
if(pv.isMine){
Debug.Log ("PhotonViewisMine");
playtoggle = false;}
}

void OnTriggerExit (Collider other){
Debug.Log ("Exit");
PhotonView pv = PhotonView.Get(this);
if (pv.isMine){
StopVideo();}

}

}[/code2]

Comments

  • alanpt
    Options
    Okay, I must have worded my question poorly.
    I'll keep working on it.

    Is there some notes on showing:

    * display on my player view but not other networked players view
    * display on my player view and other networked players view
    * don't display on my view, just other networked players view

    Cheers
  • alanpt
    Options
    I think I have it working. I am concerned that it might be using up too much resources.

    [code2=csharp]using UnityEngine;
    using System.Collections;
    public class VideoPlayer : Photon.MonoBehaviour {

    public bool playtoggle = false;

    void OnTriggerEnter(Collider other){
    Debug.Log ("Enter");
    Renderer r = GetComponent<Renderer>();
    r.enabled = true;
    }

    void OnTriggerExit (Collider other){
    Debug.Log ("Exit");
    Renderer r = GetComponent<Renderer>();
    AudioSource audio = GetComponent<AudioSource>();
    MovieTexture movie = (MovieTexture)r.material.mainTexture;
    audio.Pause();
    movie.Pause();
    r.enabled = false;
    }

    void Update() {
    Renderer r = GetComponent<Renderer>();
    AudioSource audio = GetComponent<AudioSource>();
    MovieTexture movie = (MovieTexture)r.material.mainTexture;
    if (r.enabled == true){
    if (Input.GetKeyDown(KeyCode.Space)){
    playtoggle = !playtoggle;
    if (playtoggle == true) {
    audio.Pause();
    movie.Pause();
    }else {
    audio.Play();
    movie.Play();
    }

    }

    }

    }
    }[/code2]
  • Tobias
    Options
    Thanks for the update. Sorry we couldn't help. Busy week!
    The solution seems to be no longer related to PUN, right? No isMine. It's OK. Any way that makes it work, is fine.