/
/
/ "BRO TIGER"2017-04-13 10:33:51
C++ / C#
/ "BRO TIGER", 2017-04-13 10:33:51

How to find Transform on a non-Spawned Player (Procedural Map)?

Good day... I did multiplayer for my Game, set up NetworkManager, PlayerSpawn... But the procedural map needs an "Observer" i.e. The player because of which the map will load ... And then there was a dispute between the EndlessTerrain.cs script and NetworkManager, since the Player spawns when connected to the server and the player's script does not see it. can't find "Observer"... Help! Thanks in advance!
PS Here is the part of the script with the error:

public Transform viewer;
  public Material mapMaterial;

  public static Vector2 viewerPosition;
  Vector2 viewerPositionOld;
  static MapGenerator mapGenerator;
  int chunkSize;
  int chunksVisibleInViewDst;

  Dictionary<Vector2, TerrainChunk> terrainChunkDictionary = new Dictionary<Vector2, TerrainChunk>();
  static List<TerrainChunk> terrainChunksVisibleLastUpdate = new List<TerrainChunk>();

  void Start() {
    mapGenerator = FindObjectOfType<MapGenerator> ();

    maxViewDst = detailLevels [detailLevels.Length - 1].visibleDstThreshold;
    chunkSize = mapGenerator.mapChunkSize - 1;
    chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / chunkSize);

    UpdateVisibleChunks ();
  }

  void Update() {
    viewerPosition = new Vector2 (viewer.position.x, viewer.position.z) / mapGenerator.terrainData.uniformScale;
                //Вот здесь
    if ((viewerPositionOld - viewerPosition).sqrMagnitude > sqrViewerMoveThresholdForChunkUpdate) {
      viewerPositionOld = viewerPosition;
      UpdateVisibleChunks ();
    }
  }

P.S. Scheme:
bb0902ce6dfa4a4a9534e5650c1d3c02.jpg
As you can see, first Noise (Perlin) is generated, everything is applied to the object - Plan, Then the information is compiled into a separate Data file - which in turn can be changed ... Next, MapGenerator Accepts this file, but then it sends a command to 2 other scripts that in turn generate the Mesh and Textures on the Mesh, everything again turns into a separate file and it is read by the MapGenerator... 2 of these scripts "Communicate" between the MapGenerator, and Noise is the main one in all this.... Next, the MapGenerator reads the MapDisplay - This is a script that combines all files! Next, MapDisplay sends a command to create Chunks - EndlessTerrain. Chunks are generated/disappeared at a certain distance of the player to the edge of the map (Like in Minecraft), but this requires another object that is nowhere to be found except in EndlessTerrain - "

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question