Sweeptest false positive

Hi all,

I have a simple box collider that I wish to detect as it collides with a mesh collider.
I get a ‘hit’ even though they aren’t anywhere near touching - for other reasons I can’t use the ‘usual’ collision callbacks.
Here’s my sweep test code:

Vector3 start = player.moving.transform.position;
start.x -=20;
Vector3 end = player.moving.transform.position;
end.x -=1;

Debug.DrawLine(start,end,Color.red,1);
print(player.moving.transform.parent.rigidbody);
if (player.moving.transform.parent.rigidbody.SweepTest(end,out hit,0.001f))
{
print(“hit”);
return false;
}

As you can see even moving the start end of the test way back it still triggers!!!; the range is minimal but I would say the collision is registered maybe 0.5 of a Unity world unit away.
have no idea what I am doing wrong here; any help appreciated

Cheers

Ok,

I’ve got it working with some “magic” numbers but I don’t get why I have to move my sweetest start point back so very far!:

RaycastHit hit;

Vector3 start = player.moving.transform.position;
start.x -=8.9f;
Vector3 end = start;

Debug.DrawLine(start,end,Color.red,1);
print(player.moving.transform.parent.rigidbody);
if (player.moving.transform.parent.rigidbody.SweepTest(end,out hit,0.001f))
{
print(“hit:”);
return false;
}