Huge NullReferenceException Error.
Options
N1warhead
✭✭
Here is the Error I am getting......
if it helps, the game starts fine by its self.
But when I load another instance of game to test, I don't see anything wrong, everything works as should.
But i can't quite figure out what this means.
I have been watching "quill18creates" videos on setting my game up.
But even copying his scripts to exact specs, I still get this problem.
What gets me the most, is it is talking about files I haven't even touched, etc.
Such as (PhotonNetwork/NetworkingPeer.cs:3230)
Thank you!
ERROR
Here is my NetworkCharacter Script
if it helps, the game starts fine by its self.
But when I load another instance of game to test, I don't see anything wrong, everything works as should.
But i can't quite figure out what this means.
I have been watching "quill18creates" videos on setting my game up.
But even copying his scripts to exact specs, I still get this problem.
What gets me the most, is it is talking about files I haven't even touched, etc.
Such as (PhotonNetwork/NetworkingPeer.cs:3230)
Thank you!
ERROR
NullReferenceException: Object reference not set to an instance of an object NetworkCharacter.OnPhotonSerializeView (.PhotonStream stream, .PhotonMessageInfo info) (at Assets/Scripts/System/NetworkCharacter.cs:37) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) PhotonView.ExecuteOnSerialize (.PhotonStream pStream, .PhotonMessageInfo info) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:257) NetworkingPeer.OnSerializeWrite (.PhotonView view) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3230) NetworkingPeer.RunViewUpdate () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3149) PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:90)
Here is my NetworkCharacter Script
using UnityEngine; using System.Collections; public class NetworkCharacter : Photon.MonoBehaviour { Vector3 realPosition = Vector3.zero; Quaternion realRotation = Quaternion.identity; Animator anim; // Use this for initialization void Start () { anim = GetComponent<Animator>(); if(anim == null) { Debug.LogError ("You forgot to put an Animator component on this character prefab!"); } } // Update is called once per frame void Update () { if( photonView.isMine ) { // Do nothing -- the character motor/input/etc... is moving us } else { transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f); transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if(stream.isWriting) { // This is OUR player. We need to send our actual position to the network. stream.SendNext(transform.position); stream.SendNext(transform.rotation); stream.SendNext(anim.GetFloat("Speed")); stream.SendNext(anim.GetBool("Jumping")); } else { // This is someone else's player. We need to receive their position (as of a few // millisecond ago, and update our version of that player. realPosition = (Vector3)stream.ReceiveNext(); realRotation = (Quaternion)stream.ReceiveNext(); anim.SetFloat("Speed", (float)stream.ReceiveNext()); anim.SetBool("Jumping", (bool)stream.ReceiveNext()); } } }
0
Comments
-
For anyone who has this problem in the future, I found the problem.
my OnPhotonSerializeView I had as a Public Void, it just needs to be Void!!0