- Home /
Found that i can use overlapbox to determine a terrain collider and then that terrain could use overlapbox to determine if nearby neighbour has a terraintile active or not. Its much better than shooting rays.
Spawning Terrain Around The Player
Hello Guys,
Ive Run into a bit of a problem. I am making a game where the terrain would generate around the player as the player walks around. The terrain tile i have is a big chunk and i wish to spawn others like it when necessary.
The approach i am taking is: Storing the single terrain tile as a prefab, making a giant box collider around the player. Through this, i will get the terrain collider of the terrain that is within this box collider and get the center of the terrain. This starting terrain is the one that the player spawns on. After this i will shoot rays in 8 directions (Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight) from the edge of the terrain to check if any neighbour terrain tiles are present then instantiate a terrain tile if one is not present in that area and keep doing this with other terrain tiles that touch the players box collider. I will then remove the terrain tile if the player moves a certain distance away from it.
Is this a good approach or are there any other more convenient/simpler approaches than this?
In the picture uploaded, the blue big tile is what the terrain looks like. The small highlighted object in green in the middle is the player, and the large orange highlighted object is the box collider that will check for terrain.
Any help is greatly appreciated. Tyvm in advance.
Follow this Question
Related Questions
Destroy Terrain trees and their colliders. 0 Answers
Destroy Terrain Trees And Their Colliders 0 Answers
3D box collider go through terrain 1 Answer
Destroy Terrain Trees And They Collider 0 Answers
Unity Collider Penetrating detection 0 Answers