SphereCast with terrain failed

hi guys
i find something very weird
i use Physics.SphereCastAll to find some point in the terrain for my character,the code is like this:
Physics.SphereCastAll( 10000.0f, 0.2f, Vector3.down, 15000.0f, ( int )Game.Define.LayerFlags.Standable );
with very low possiblity,the cast will failed to find a collision,it means i can not place my character

i do some other experiment, and i find that:

when the the distance is closer to the terrain ,the fail possibility will be lower
it seems the result may have something with the float number precision,but as far as i know,the distance in this kind of collision detection algorithm does not matter

if i use Physics.CapsuleCastAll the will be much change to fail
if i use Physics.RayCastAll, it won’t fail (at least in my experiment)

so i think it might be a bug for TerrainCollider anyone have the same problem? or anyone knows what’s going on

I’ve used SphereCastAll on terrain and it works fine for me. I suspect you might have an error somewhere. Are you sure your layer flags are correct? If your terrain is on layer 7 for instnace, the flag should be (1 << 7), not 7.

Also, the way you have it written won’t work; the first argument needs to be a vector, the origin position of the sphere. If you’re using javascript maybe it’s converting that 10000f into 0,0,0? The first argument should be the position of your character.

thanks for reply
Sorry for not having a clear description
i am sure the collision mask flag is passed corrrectly an the first parameter is also right(in fact i just use the player’s current position + vector.up * 10000.0f)
could do me a favor to generate some random point within the terrain and cast them onto the terrain? thanks

here is a simple test script

using UnityEditor;
using UnityEngine;

using System;

namespace ForEditor.Test
{
	static class TerrainRayCastTest
	{
		[MenuItem( "Test/Terrain/Sphere Cast All" )]
		static void SphereCastAll()
		{
			if( Selection.activeGameObject == null || !Selection.activeGameObject.GetComponent<Terrain>() )
				Debug.LogError( DateTime.Now + "\tselect terrain!" );
			else
			{
				var			terrain = Selection.activeGameObject.GetComponent<Terrain>();
				var			data = terrain.terrainData;
				var			size = data.size;

				for( var i = 0; i < 100; ++i )
				{
					var			x = UnityEngine.Random.value * size.x;
					var			z = UnityEngine.Random.value * size.z;
					var			position = new Vector3( x, 10000, z );

					var			hits = Physics.SphereCastAll( position, 0.2f, Vector3.down, 20000 );
					var			index = Array.FindIndex( hits, hit => hit.collider.gameObject.GetInstanceID() == Selection.activeGameObject.GetInstanceID() );

					if( index < 0 )
					{
						Debug.LogError( position + "/" + hits.Length );
						foreach( var hit in hits )
							Debug.Log( "\t" + hit.point );
					}
				}
			}
		}
	}
}

to use it u should first select the terrain object in the hierarchy window and click the menu “Test/Terrain/Sphere Cast All” is sphere failed the will be a error log