Having multiple UNET errors that I believe are caused by unity itself. Am I doing something wrong?
Hi all, I've been working on an arena-styled FPS game for about a month. Everything was working fine (more or less) until recently, and now Unity Networking is giving me countless errors and I'm not sure what I did to break the game.
Included in these errors are:
Assertion failed: Invalid worldAABB. Object is too large or too far away from the origin.
IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:4 pos:4
rigidbody.velocity assign attempt for 'Rifle(Clone)' is not valid. Input velocity is { 22710413426688.000000, 389.803223, NaN }.UnityEngine.Networking.NetworkTransform:FixedUpdate()
It should be noted that I'm not using custom messages of any sort, only Commands and RPC calls. Nor am I manually assigning a velocity to a rigidbody other than that of the player's, so a gun's rigidbody shouldn't be getting bad values for velocities. I've even implemented:
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
base.OnDeserialize(reader, initialState);
}
as I've seen other people suggest, but that simply got rid of some of the IndexOutOfRangeExceptions
and added the Assertion failed error.
Symptoms (of likely these bugs) include:
Players spawning in sometimes go
flying for no reason, even though
they spawn in the air, and away from
any immediate collisions
Guns that are spawned show up fine
for the server, but flicker and jump
around on the clients. In fact,
sometimes the clients can't see the
gun at all until they stand on the
spawner and pick it up. They can
(almost) always pick up the gun
whether or not they see it, and the
server always sees the guns in the
right places.
Occasionally, the Command and RPC
calls for the death function won't be
called, and the players will still be
alive with negative health. This is
an incredibly rare error though, and
may just be my faulty code
This is the first Unity game that I've ever gotten this far in, and I don't want to give up just because of some potentially easy-to-fix errors. I'm willing to provide whatever it takes to help diagnose these issues, though I'm very reluctant to post the entire project folder.
The last time I used Unity was back in 4.x, so I'm still fairly new to the whole UNET thing (though I must say, I like it much better than the old networking system). I really appreciate any and all help, and I wish you all the best. Thanks :)
Edit: Forgot to mention: I mostly fixed the "spawn in and fly away" bug by setting the rigidbody's velocity to {0, 0, 0} in the player's start method. However, before adding the Override OnDeserealize method to a bunch of NetworkBehavoiur scripts, this was never an issue, and I don't want to have to worry about the players randomly flying away during gameplay (as this has also happened on occasion). However, in all of my testing, this only happened to clients. The server seems to be safe from almost all of these bugs, leading me to believe there's an issue with the networking code.
Edit 2: The items that the Assertion failed: Invalid worldAABB. Object is too large or too far away from the origin.
error is talking about are not even out of the map, which is no bigger than 500 by 500 units
Hi, I'm having the same problem. Have you solved it?
Answer by unity_U4rY6T_9hPhqdQ · Jun 06, 2018 at 02:25 PM
Okay, actually I just found a way to solve this.
I used the following: https://forum.unity.com/threads/unet-hlapi-pro-taking-unet-to-the-next-level.425437/
and it solved all those issues, but you have to remove all the OnDeserialize functions you've added.
Your answer
Follow this Question
Related Questions
Cannot attach game object to script. 0 Answers
How to instantiate a game object every time when space key is pressed 2 Answers
Input Command Issues 0 Answers