public void Update() { // don't load chunks if engine isn't initialized yet if (!Engine.Initialized || !ChunkManager.Initialized) { return; } // don't load chunks if multiplayer is enabled but the connection isn't established yet if (Engine.EnableMultiplayer) { if (!Network.isClient && !Network.isServer) { return; } } // track which chunk we're currently in. If it's different from previous frame, spawn chunks at current position. currentPos = Engine.PositionToChunkIndex(transform.position); if (currentPos.IsEqual(LastPos) == false) { //ChunkManager.SpawnChunks(currentPos.x, currentPos.y, currentPos.z); StartCoroutine(ReplaceChunks(currentPos)); // (Multiplayer) update server position if (Engine.EnableMultiplayer && Engine.MultiplayerTrackPosition && Engine.UniblocksNetwork != null) { UniblocksClient.UpdatePlayerPosition(currentPos); } } LastPos = currentPos; }
public static void SpawnChunks(float x, float y, float z) { // take world pos, convert to chunk index Index index = Engine.PositionToChunkIndex(new Vector3(x, y, z)); Engine.ChunkManagerInstance.TrySpawnChunks(index); }
public static void SpawnChunks(Vector3 position) { Index index = Engine.PositionToChunkIndex(position); Engine.ChunkManagerInstance.TrySpawnChunks(index); }
public static void SpawnChunks(float x, float y, float z) { Index index = Engine.PositionToChunkIndex(new Vector3(x, y, z)); Engine.ChunkManagerInstance.TrySpawnChunks(index); }