Onplayer :
void Update()
{
if (photonView.isMine)
{
mpos = Input.mousePosition;
}
}
private void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.isWriting)
{
stream.SendNext(vur);
stream.SendNext(mpos);
}
else if (stream.isReading)
{
mpos = (Vector3)stream.ReceiveNext();
vur = (int)stream.ReceiveNext();
}
}
OnBall :
private void OnCollisionStay(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
oyuncu = collision.gameObject;
script = oyuncu.GetComponent<oyuncukontrol>();
Ray ray = Camera.main.ScreenPointToRay(script.mpos);
RaycastHit hit;
if (script.vur == 0)
{
if (Physics.Raycast(ray, out hit, 100))
{
targetPos = hit.point;
}
}
}
}
}
Error :
InvalidCastException: Specified cast is not valid.
oyuncukontrol.OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) (at Assets/Scripts/oyuncukontrol.cs:77)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <d7ac571ca2d04b2f981d0d886fa067cf>:0)
PhotonView.ExecuteComponentOnSerialize (UnityEngine.Component component, PhotonStream stream, PhotonMessageInfo info) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:553)
PhotonView.DeserializeComponent (UnityEngine.Component component, PhotonStream stream, PhotonMessageInfo info) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:378)
PhotonView.DeserializeView (PhotonStream stream, PhotonMessageInfo info) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:363)
NetworkingPeer.OnSerializeRead (System.Object[] data, PhotonPlayer sender, System.Int32 networkTime, System.Int16 correctPrefix) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4409)
NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2638)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at <5b2c7915d6ca43908ac03c52eb97ef22>:0)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at <5b2c7915d6ca43908ac03c52eb97ef22>:0)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at <5b2c7915d6ca43908ac03c52eb97ef22>:0)
PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:161)
Problem at mpos = (Vector3)stream.ReceiveNext();