I am only 13 so my code is gonna be a little rusty but I am trying to break a heightmaps into chunks that can be culled when the player does not see it but when making my script that makes the terrains I just get infinite clones. Any help would be very apreciated!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChunkColumns : MonoBehaviour {
string num;
public bool apply;
public int LengthHorizontally;
public int LengthVertically ;
public int TileResolution;
public int VisionRadius;
int terrainSizeX;
int terrainSizeY;
public GameObject Player;
public GameObject Column;
// Use this for initialization
void Start()
{
num = this.gameObject.name;
char[] Num = num.ToCharArray();
Apply();
}
void Apply () {
terrainSizeX = LengthHorizontally % TileResolution;
terrainSizeY = LengthVertically % TileResolution;
Vector3 Position = this.transform.position;
Position.x = Position.x + terrainSizeX;
Position.y = Position.y + terrainSizeY;
Quaternion NormRot = this.transform.rotation;
if (transform.position.x < LengthHorizontally) {
GameObject ColumnNum = Instantiate(Column, Position, NormRot) as GameObject;
}
}
// Update is called once per frame
void Update () {
}
}