- Home /
sync video on all network clients
I've an object with a movietexture and i need to play this video from a non-authoritatice server in a way that it plays simultaneously in all the clients. I've networkview on this object but it doesn't get synchronized this way. I can see the every player that enters the game with their animations but just not this object. Video is being played from this script:
if (Input.GetButtonDown ("")) { if (renderer.material.mainTexture.isPlaying) { renderer.material.mainTexture.Pause(); other.audio.Pause(); } else { renderer.material.mainTexture.Play(); other.audio.Play(); } }
This is what my OnSerializeNetworkView looks like:
if (stream.isWriting){
var pos : Vector3 = transform.position;
stream.Serialize(pos);//"Encode" it, and send it
}else{ var posReceive : Vector3 = Vector3.zero; stream.Serialize(posReceive); transform.position = posReceive;
}
What am i doing wrong?
Answer by Tarun · Oct 04, 2010 at 04:29 PM
the fact that network view is added to your gameobject doesn't ensure that its contents like textures are synchronized. The movie texture you have is probably on a static screen but you are capturing its movements on OnSerializeNetworkView. Hence no effect on video being played.
Try this: Create 2 cubes, 1 for Play and 1 for Stop. Place them below your screen. Put NetworkView on both these buttons/gameobjects. On MouseDown, change X/Y/Z value on the button so that it looks as if its pressed. This will synchronize its position on all the clients and all the clients will know if someone tried to play or stop the video. Find the tag of the video screen and play its video once the play or stop is pressed. This way videos will be synchronized based on the MouseDown events on Play/Stop gameobjects.
(funny we share the same name) - hope this works.
had a typo on my name :-)...corrected it. Well not sure if this is the most efficient way to do this but it worked. Thanks!