Hey,
At the first I´m sorry about my grammar, I´m German
I have a big problem with my game, everthing works awesome on multiplayer, but the players are not smooth.
Here is my multiplayer mainscript:
using UnityEngine;
using System.Collections;
public class MPSpawnScript : MonoBehaviour
{
public Transform player;
void OnServerInitialized()
{
SpawnPlayer();
}
void OnConnectedToServer()
{
SpawnPlayer();
}
void SpawnPlayer()
{
Network.Instantiate(player, transform.position, transform.rotation, 0);
}
void OnPlayerDisconnected(NetworkPlayer player)
{
Network.RemoveRPCs(player);
Network.DestroyPlayerObjects(player);
}
void OnDisconnectedFromServer(NetworkDisconnection info)
{
Network.RemoveRPCs(Network.player);
Network.DestroyPlayerObjects(Network.player);
Application.LoadLevel(Application.loadedLevel);
}
}
Its very simple.
And then the playerscript:
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
if (stream.isWriting)
{
Vector3 pos = transform.position;
stream.Serialize(ref pos);
}
else
{
Vector3 posRec = Vector3.zero;
stream.Serialize(ref posRec);
transform.position = posRec;
}
}
I hope anyone know whats going wrong ^.^
Here is a video: - YouTube