Many people find Spherecast and want to use it to test a sphere around origin (usually a player or unit), like testing one direction with a ray except in a sphere with the ray as radius. This is not what it is meant for.
In a nut-shell: Spherecasting is designed to cast a “thick ray” by sending a sphere of size (origin, radius) down a ray (origin, direction, length) and returns an array of raycastHits: raycastHit[ ] (out hitInfo) that collides with the sphere if they are both on the correct layers (layerMask).
Frankly it would be nice to be able to do a local sphere cast with direction and distance either zero, or equal to origin and radius, but it doesn’t do this. My one quick test showed I needed to have a direction and at least a microscopic distance for the Spherecast to work.
I’ve been looking into this a bit, as I’ve been trying to practice getting movement collision. In the end, I found that I had assumed that “distance” referred to “how far the trace went”, when it is, in fact, just the distance to the hit point from the beginning of the trace (unless I’m mistaken).
Ended up doing a little unity test which might help people understand what the sphere cast does… maybe?
I’ve been looking for this information. Thanks for sharing. So, SphereCast is like throwing a ball (or drawing with a thick rollerball pen) while Ray cast is similar to poking an object with a thin stick.
So, the only difference from a normal ray is the thickness? Handy for a lot of various things. But other than the thickness, is this identical to a ray?
I actually have a rocket which blows up. At blow up, with a trigger, I expand its size, not gradually however, my initial tests did not inflict the damage, I suppose since no collider “entered” this expanded trigger collider. This might be a very useful solution no?