private void Awake() { nt = GetComponentInParent <PlayerNetworkTransform>(); rb = GetComponent <Rigidbody2D>(); initialGravityScale = rb.gravityScale; try { var colliders = GetComponents <Collider2D>(); collider = colliders.First(d => d.enabled && d.isTrigger); } catch (Exception e) { if (collider == null) { Debug.LogWarning("Trigger collider needed for detecting ground collisions"); Debug.Break(); } } floorLayer = LayerMask.NameToLayer(FloorLayerStr); if (floorLayer == -1) { Debug.LogWarning("Floor layer name needed"); Debug.Break(); } if (Energy == null) { Energy = GetComponent <EnergyCarrier>(); } }
void ClientReceiveUpdate(NetworkMessage message) { ServerStateUpdate updateMessage = message.ReadMessage <ServerStateUpdate>(); NetworkInstanceId netId = new NetworkInstanceId(updateMessage.netId); GameObject foundObj = ClientScene.FindLocalObject(netId); if (foundObj == null) { return; } if (message.conn.playerControllers[0].unetView.netId == netId) { PlayerNetworkTransform networkTransform = foundObj.GetComponent <PlayerNetworkTransform>(); //Update the player network transform from the server networkTransform.OnServerFrame( new PlayerState( updateMessage.Origin, updateMessage.Velocity ) ); } }