Answer the question
In order to leave comments, you need to log in
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 ();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question