- Home /
OnSerializenetworkView not doing anything??
Hi.. well, I have no idea what I'm doing wrong here. I am trying to sync the position of my car using the OnSerializenetworkView function so that I can later add in dead reckoning.
I already have the script in the observed part of the network view with it set to "unreliable", and for some reason, nothing is happening in the function. Neither print("Sending"); or print("Reciving"); is showing up.
Elsewhere in the code, I do have a few RPC's and they are all working fine.
Anyone have any idea what I could be doing wrong?
function OnSerializenetworkView(stream:BitStream,info:NetworkMessageInfo){
if(stream.isWriting)
{
print("Sending");
var pos:Vector3=transform.position;
stream.Serialize (pos);
}
else
{
print("Reciving");
var posReceive:Vector3=Vector3.zero;
stream.Serialize(posReceive);
transform.position=Vector3.Lerp(transform.position,posReceive,0.9);
}
}
I just tested that now. It does the exact same thing with several clients.
Answer by Kryptos · Jan 18, 2012 at 08:18 AM
Spelling mistake: the correct name for this method is OnSerializeNetworkView (with a big 'N').
Oh boy... 5 hours wasted on that one lowercase letter. Thankyou so much! Now I can get back to working on more important stuff. :D
It can happen to anyone.
One advice: copy/paste method name from Unity documentation. I do it every time I use a new method. After that I can copy/paste my own piece of code.
Your answer
Follow this Question
Related Questions
OnTriggerEnter not working 0 Answers
Why isn`t my 2D AddTorque working? 2 Answers
troble with the Axis in unity 1 Answer