Hi everyone,
Currently I am making a 3D game with a orthographic camera and I have met this problem.
The problem is the orthographic camera is keep clipping the terrain, since there is a mountain. I have tried to adjust the “Clipping Plane” but it did not feels right.
Yes, it will not clipping inside the mountain anymore but I cannot see my character on that angle with the mountain.
I also have tried “CineMachine” but still this is a orthographic camera and I also tried to make a “ClippingDetector” script which will detect whether the view of the camera is clipping inside a terrain.
Here is script:
using UnityEngine;
public class TerrainClippingDetector : MonoBehaviour
{
public Camera camera;
public Terrain terrain;
void Update()
{
// Get the camera's frustum planes
Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes(camera);
// Get the terrain's bounds
Bounds terrainBounds = terrain.terrainData.bounds;
terrainBounds.center = terrain.transform.position + terrainBounds.center;
// Check if the terrain is being clipped
bool isClipped = !GeometryUtility.TestPlanesAABB(frustumPlanes, terrainBounds);
if (isClipped)
{
Debug.Log("The terrain is being clipped by the camera's frustum.");
}
else
{
Debug.Log("The terrain is fully visible.");
}
}
}
Here is some image:
Still no results…
Is there any solution for this, thank you for your help.
