While this works, I would like to correctly typecast different variable types from a PhotonStream read (in Unity JavaScript) :
function OnPhotonSerializeView( stream : PhotonStream, info : PhotonMessageInfo )
{
if ( stream.isWriting )
{
// We own this player: send the others our data
stream.SendNext( transform.position );
stream.SendNext( transform.rotation );
stream.SendNext( desiredVelocity );
stream.SendNext( inputVector );
stream.SendNext( moveSpeed );
}
else
{
// Network player, receive data
transform.position = stream.ReceiveNext(); // ( Vector3 )stream.ReceiveNext();
transform.rotation = stream.ReceiveNext(); // ( Quaternion )stream.ReceiveNext();
desiredVelocity = stream.ReceiveNext(); // Vector3
inputVector = stream.ReceiveNext(); // Vector3
moveSpeed = stream.ReceiveNext(); // float
}
}
↧