Hi guys ,I am using a simple follow camera that always stays above the terrain ,and I am trying to stop the camera getting too close to my vehicle ,can anyone tell me why the code isn’t quite correct please ? (the terrain height works ,but I cannot seem to limit the near distance)
var target : Transform;
function FixedUpdate () {
transform.position = Vector3.Lerp (transform.position, target.position + Vector3.up * 5, Time.deltaTime * 160 * Time.deltaTime);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target.position - transform.position, target.up), Time.deltaTime * 2);
transform.position.y = Terrain.activeTerrain.SampleHeight(transform.position)+5;
if (transform.position.x <=10) transform.position.x =10;
if (transform.position.z <=10) transform.position.z =10;
}