I was trying to use physics.OverlapBox
as a Check Area, And wanted to use Gizmos
to visualize it.
They're both the same size.. or at least should be, But it seems the Check Area is bigger than the Gizmo.
Both physics.OverlapBox
and Gizmos
are at a point in front of the player.
I know the code is not great but this is just to test it out:
private void OnDrawGizmos()
{
Gizmos.color = new Color(0.75f, 0.0f, 0.0f, 0.5f);
Gizmos.DrawCube(_shootArea.position, new Vector3(2,2,2));
}
void Update()
{
Collider[] footballInRange = Physics.OverlapBox(_shootArea.position, new Vector3(2,2,2), Quaternion.identity, _layerFootball);
foreach (var footBall in footballInRange)
{
Debug.Log("Ball In Collider At " Time.frameCount);
}
}
CodePudding user response:
Take a closer look at the Physics.OverlapBox and Gizmos.DrawCube declarations.
public static Collider[] OverlapBox(Vector3 center, Vector3 halfExtents, [...]);
public static void DrawCube(Vector3 center, Vector3 size);
If you use the same dimensions for both the overlapbox will be twice as big as the displayed gizmo.
Either make the gizmo twice as large or the box half as small.