Photon Unity Networking (Viking Demo) Error: Argument is out

Hi,

I'm a newbie developer on Photon Cloud and Unity 3D. I'm working on this Viking Demo http://u3d.as/content/exit-games/photon-viking-demo/2gg. But in this tutorial when player jumped other player cant see the jump animation. We can only see the negative force effect of gravity. in brief, Jump animation unable to see by the other player. How can i make visible this for other player. Truly I need help. Thanks for your interest.

--- EDIT: We have reached an important milestone and question has been changed ---

I'm developing a MMO. I'm using for networking Photon Viking Demo-http://u3d.as/content/exit-games/photon-viking-demo/2gg. In this demo only position, rotation, rigidbody and walk/run animations are synchronized (for players. I'm trying to make synchronized attack or jump animations. I did simple changes on "ThirdPersonNetworkVik.cs". Here is the original codes of "ThirdPersonNetworkVik.cs":

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)

{

if (stream.isWriting)

{

//We own this player: send the others our data

// stream.SendNext((int)controllerScript._characterState);

stream.SendNext(transform.position);

stream.SendNext(transform.rotation);

stream.SendNext(rigidbody.velocity);



}

else

{

//Network player, receive data

//controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();

correctPlayerPos = (Vector3)stream.ReceiveNext();

correctPlayerRot = (Quaternion)stream.ReceiveNext();

rigidbody.velocity = (Vector3)stream.ReceiveNext();

}

}



private Vector3 correctPlayerPos = Vector3.zero; //We lerp towards this

private Quaternion correctPlayerRot = Quaternion.identity; //We lerp towards this



void Update()

{

if (!photonView.isMine)

{

//Update remote player (smooth this, this looks good, at the cost of some accuracy)

transform.position = Vector3.Lerp(transform.position, correctPlayerPos, Time.deltaTime * 5);

transform.rotation = Quaternion.Lerp(transform.rotation, correctPlayerRot, Time.deltaTime * 5);

}

}

And these codes edited by me for open a stream and send LeftControl key if pressed LeftControl button and update the other player and play the animation. Edited script "ThirdPersonNetworkVik.cs" >> at attachments

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)

{

if (stream.isWriting)

{

//We own this player: send the others our data

// stream.SendNext((int)controllerScript._characterState);

stream.SendNext(transform.position);

stream.SendNext(transform.rotation);

stream.SendNext(rigidbody.velocity);



//ADDED CODE BLOCK

if (Input.GetKeyDown(KeyCode.LeftControl))

{

stream.SendNext(KeyCode.LeftControl);

}//ADDED CODE BLOCK



}

else

{

//Network player, receive data

//controllerScript._characterState = (CharacterState)(int)stream.ReceiveNext();

correctPlayerPos = (Vector3)stream.ReceiveNext();

correctPlayerRot = (Quaternion)stream.ReceiveNext();

rigidbody.velocity = (Vector3)stream.ReceiveNext();



//ADDED CODE BLOCK

keycode55 = (KeyCode)stream.ReceiveNext();

//ADDED CODE BLOCK

}

}



private Vector3 correctPlayerPos = Vector3.zero; //We lerp towards this

private Quaternion correctPlayerRot = Quaternion.identity; //We lerp towards this



//ADDED CODE BLOCK

private KeyCode keycode55 = KeyCode.None;

//ADDED CODE BLOCK



void Update()

{

if (!photonView.isMine)

{

//Update remote player (smooth this, this looks good, at the cost of some accuracy)

transform.position = Vector3.Lerp(transform.position, correctPlayerPos, Time.deltaTime * 5);

transform.rotation = Quaternion.Lerp(transform.rotation, correctPlayerRot, Time.deltaTime * 5);



//ADDED CODE BLOCK

if (keycode55 == (KeyCode.LeftControl))

{

transform.Find("baseMale").animation["basemeleeattack1"].wrapMode = WrapMode.Once;

transform.Find("baseMale").animation.Play("basemeleeattack1");

keycode55 = KeyCode.None;

}

//ADDED CODE BLOCK

}

}

And I'm getting an error because of I used this if statement:
if (Input.GetKeyDown(KeyCode.LeftControl))

When I didn't use this if statement im not getting any error but the character continuously play attack animation forever.

Here is the error:


ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System.Collections.Generic.List`1[System.Object].get_Item (Int32 index) (at /Applications/buildAgent/work/84669f285f6a667f/mcs/class/corlib/System.Collections.Generic/List.cs:633) PhotonStream.ReceiveNext () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs:244)

PhotonClasses.cs >> at attachments

Comments