Ok so what is happening is my camera is switching between players so the other player looks though my screen/camera and i look though his camera.
how i set it up is that one player is the batmobile and the other is a race car. they are both prefabs with its own camera attached to it and movement script.
when I start the server on my end before anyone connects then it works fine im behind the batmobile. But the second he joins the game i switch behind the race car and his camera is behind the batmobile.
The movement script still works fine I control the batmobile and he controls the race car but the cameras are screwy.
Thanks for any help with this Im stumped about this.
here is the network scripts Thanks again for any help
var playerPrefab : GameObject;
var batPrefab : GameObject;
var sp1 : Transform;
var sp2: Transform;
private var hostData: HostData[];
private var refreshing : boolean;
var bX : float;
var bY : float;
var bW : float;
var bH : float;
function Start()
{
bX = Screen.width * 0.1;
bY = Screen.width * 0.1;
bW = Screen.width * 0.1;
bH = Screen.width * 0.1;
}
function Update()
{
if(refreshing)
{
if(MasterServer.PollHostList().Length > 0)
{
refreshing = false;
Debug.Log(MasterServer.PollHostList().Length);
hostData = MasterServer.PollHostList();
Debug.Log("Host data lenght ;" + hostData.Length);
}
}
}
function startServer()
{
Network.InitializeServer(32,25000,!Network.MovePublicAddress);
MasterServer.RegisterHost(gameName, "Batman Driver game", "This is a test");
}
function OnServerInitialized()
{
Debug.Log("Server initilized");
spawnPlayer();
}
function OnMasterServerEvent(mse:MasterServerEvent)
{
if(mse == MasterServerEvent.RegistrationSucceeded)
{
Debug.Log("Server Registered");
}
}
function refreshHostList()
{
Debug.Log("Refreshing");
MasterServer.RequestHostList(gameName);
refreshing = true;
}
function OnConnectedToServer()
{
spawnPlayer();
}
function spawnPlayer()
{
if(Network.isClient)
{
Network.Instantiate(playerPrefab, sp2.position, Quaternion.identity, 0);
}
if(Network.isServer)
{
Network.Instantiate(batPrefab, sp1.position, Quaternion.identity, 0);
}
}
function OnGUI()
{
if(!Network.isClient && !Network.isServer)
{
if(GUI.Button(Rect(bX, bY, bW, bH), "Start Server"))
{
Debug.Log("Server Start");
startServer();
}
if(GUI.Button(Rect(bX, bY * 1.2 + bH, bW, bH), "Refreash Host"))
{
refreshHostList();
}
//this works
//GUI.Button(Rect(bX * 1.5 + bW, bY * 1.2 + (bH * 0), bW *3 , bH * 0.5), "Game test");
if(hostData)//if statement works
{
var hdLenght = hostData.Length;
//GUI.Button(Rect(bX * 1.5 + bW, bY * 1.2 + (bH * 0), bW *3 , bH * 0.5), "Game test");\
for(var i: int = 0; i < hdLenght; i++)
{
Debug.Log("Game name :" + hostData[0].gameName);
if(GUI.Button(Rect(bX * 1.5 + bW, bY * 1.2 + (bH * i), bW *3 , bH * 0.5), hostData*.gameName))*
_ Network.Connect(hostData*);_
_ }*_
* }*
* }*
* }*
}