Non Player spawned object shooting back to its spawn point in game play.

Hi all,

Almost finished my new game, Lawn Bowls VR multiplayer and coming across a strange problem with 1 of the spawned non player objects.

Versions of Unity I have tried, all with latest patches.

5.4.2
5.6.2
2017

Basics are,

Some of it might seem long winded but I am still learning.

I am using a combination of Unity Editor and Standalone or both Standalone.

Combination of Windows 10 And Windows 7.

10 to 7
10 to 10

Happens over Internet and over locan LAN.

In earlier version of Unity we got this problem a lot, but seems to be a lot better but still a pain.

  1. 2 Player multiplayer with a maximum of 4 (2 in while testing)
  2. Using HLAPI for the UNET.
  3. Using Network Manager HUD and the default Network Manager (No Bespoke other than added objects to list of registered list) Image attached.

  1. All objects are Prefabs in the Resources Directory.
  2. All objects are spawned in exactly the same way, code example attached. (8 Bowls and 1 Jack), Spawned on the server via a [Command]

The Jack

GameObject jackBowl = Instantiate(lawnBowlJack, new Vector3(64f,1.5f,11f), Quaternion.identity) as GameObject;
jackBowl.GetComponent().bowlID = 99;
jackBowl.GetComponent().isKinematic = false;
jackBowl.GetComponent().useGravity = true;
NetworkServer.Spawn(jackBowl);

The Bowls

GameObject blueBowl1 = Instantiate(lawnBowlBlue, ViveManager.ViveInstance.bowlSpawnBlue.position, Quaternion.identity) as GameObject;
GameObject blueBowl2 = Instantiate(lawnBowlBlue, ViveManager.ViveInstance.bowlSpawnBlue.position + new Vector3(0,0,0.2f), Quaternion.identity) as GameObject;
GameObject blueBowl3 = Instantiate(lawnBowlBlue, ViveManager.ViveInstance.bowlSpawnBlue.position + new Vector3(0.2f, 0, 0.2f), Quaternion.identity) as GameObject;
GameObject blueBowl4 = Instantiate(lawnBowlBlue, ViveManager.ViveInstance.bowlSpawnBlue.position + new Vector3(0.2f, 0, 0f), Quaternion.identity) as GameObject;

blueBowl1.GetComponent().bowlID = 1;
blueBowl1.GetComponent().isKinematic = false;
blueBowl1.GetComponent().useGravity = true;
NetworkServer.Spawn(blueBowl1);
Rpc_CreateBowlArrays(blueBowl1, 0);

blueBowl2.GetComponent().bowlID = 2;
blueBowl2.GetComponent().isKinematic = false;
blueBowl2.GetComponent().useGravity = true;
NetworkServer.Spawn(blueBowl2);
Rpc_CreateBowlArrays(blueBowl2, 0);

blueBowl3.GetComponent().bowlID = 3;
blueBowl3.GetComponent().isKinematic = false;
blueBowl3.GetComponent().useGravity = true;
NetworkServer.Spawn(blueBowl3);
Rpc_CreateBowlArrays(blueBowl3, 0);

blueBowl4.GetComponent().bowlID = 4;
blueBowl4.GetComponent().isKinematic = false;
blueBowl4.GetComponent().useGravity = true;
NetworkServer.Spawn(blueBowl4);

  1. The Game play is as follows. The first player (Client, Not the Host/Client/Server) presses the Left Mouse and grabs the jack to a Bowling point at the bas of their spawned avatar. (Works great)
  2. At this point the Authority of all the Non player objects is assigned to the current player (ConnectionID). Code below. (Works Great checked in editor and all authority has changed)
  3. Presses the Left Mouse again to increase bowl power and releases to release the jack at the set velocity (Works Great)
  4. On the next press of the Left Mouse, the first bowl is picked up (Works Great)
  5. At this point the Authority of all the Non player objects is assigned to the current player (ConnectionID). (Works Great checked in editor and all authority has changed)
  6. Presses the Left Mouse again to increase bowl power and releases to release the bowl at the set velocity (Works Great)
  7. Then comes the Player that is using the Host/Server machine.
  8. Presses Left Mouse and picks up the first Bowl, (Works Great but.)
  9. At this point for some inexplicable reason the Jack jumps back to its spawn position (On the Remote Client, Server/Host still looks fine.) and is no longer syncing to the Remote clients, however if I
    hit the Jack with one of the Bowls on the Server/Host then it resyncs, otherwise we have to reset the game.
  10. This happens sparodically throughout the game, sometimes more often than not, we played for 3 hours the other night and it happened twice, last night just over an hour and we lost count of how many times
    and didn’t even finish a game.

AuthorityID[ ] obja = GameObject.FindObjectsOfType();

foreach (AuthorityID obj in obja)
{
Debug.Log("Object to Authorise = " + obj.gameObject.tag);

if (obj.gameObject != null)
{
if (obj.gameObject.GetComponent().clientAuthorityOwner != null)
{
obj.gameObject.GetComponent().RemoveClientAuthority(obj.gameObject.GetComponent().clientAuthorityOwner);
}

Debug.Log("Current Authoriser = " + connectionToClient.connectionId);

obj.gameObject.GetComponent().AssignClientAuthority(connectionToClient);
}
}

Video attached of the Server/Host at the point of picking up a bowl while viewing the Synced bowls from the remote client.

Video attached of the Remote Client at the point of the Server/Host picking up the bowl and the Jack shooting back to the Spawn point.

Any advice or help would be massively appreciated.

Thanks

Mike

This is one of those times where you confuse what’s going on on the different instnaces (Server & Clients). Easiest way is probably to run two instances. On one instance, you want to run a Server only. Not a Host (Server & Client). That should be ran in Editor.Then run another one as Client only, that could be standalone. Then do each step. and carefully watch what’s going on while you do things step by step.

Then eventually. You will notice that something is not the same across the two. Then you know where the issue is.
Hope this helps you.

  • TwoTen

Hi,

I will give that a try now.

Thank you, I have yet to run a server only setup.

Mike