Hello,
I am currently having a problem where I am trying to get the closest point on a Terrain Collider.
Code in question:
Vector3 directionToObstacle;
//Get the direction to the obstacle based on how close it is to the agent on the closest point
if (obstacleCollider is TerrainCollider)
{
Debug.Log("is terrain");
var position = _transform.position;
directionToObstacle =GameManager.instance.terrainCollider.ClosestPoint(position) -
position;
}else
{
var position = _transform.position;
directionToObstacle= obstacleCollider.ClosestPoint(position) - position;
}
When using this, terrainCollider.ClosestPoint() throws a warning stating that this can’t be used. While that’s fine, upon looking into documentation, it seems to be supported? I know Terrain Collider inherits Collider, which is why they can’t block it off.
Is there an equivalent for Terrains? Or am I going to have to make my own solution?
Thanks!
