I am attempting to find all colliders within a sphere volume. To do this I am using
Physics.SphereCastAll. However, I do not need to send the sphere along a path and I am running into a few problems because of this.
- When distance is set to 0, no colliders are found.
- When distance is set to a small value (.1),
RaycastHitsare only found at the borders of the sphere. The interior of the sphere does not trigger hits at the starting position.
The hit testing works as expected if I move the sphere beyond its starting position. For example, if I move the sphere back by a diameter, and set distance = diameter, I get the results I expect.
However, this is not ideal for two reasons:
- It seems hacky - I feel like the
Physics.SphereCastAllis not behaving as expected
- If I have objects at the position where I am now starting the
SphereCast, some of them will trigger hits. This is not desired because they are outside the real volume I am testing.
How can I accomplish this stationary SphereCast without changing the position? Should I be using some other method?
I can share more code or pictures if needed. The objects I am detecting hits on is a 3d grid of 1x1x1 cubes.