Hello,
I created 2 entities on the server, a player and a cube.
These 2 entities communicate their position at the moment whenever it changes.
The problem is that I get busy, when I move one and after a few seconds, the server crash for no apparent reason.
I tried to move an entity without the other being present, it works correctly.
When I display a debug message in the client code that displays the entity ID, everything works fine …
Your message:
"An unhandled exception of type ‘System.ArgumentOutOfRangeException’ occurred in mscorlib.dll
Additional Information: The index was out of bounds. It must not be negative and must be less than the size of the collection. "
CLIENT
void Update()
{
NetOutgoingMessage outMsg = NetworkManager.Instance.client.CreateMessage();
outMsg.Write((int)PackType.ENTITY_POSITION);
outMsg.Write(networkActor.ID);
outMsg.Write(transform.position.x);
outMsg.Write(transform.position.y);
outMsg.Write(transform.position.z);
NetworkManager.Instance.client.SendMessage(outMsg, NetDeliveryMethod.UnreliableSequenced);
}
SERVER
PackType type = (PackType)inMsg.ReadInt32();
ID = inMsg.ReadInt32();
PositionX = inMsg.ReadFloat();
PositionY = inMsg.ReadFloat(); // BUG
PositionZ = inMsg.ReadFloat();
Thank you for your help.