- Home /
SphereCast around/surrounding my object?
So I'm working on some hearing sense for my AI. Basically I want to create a sphere cast around my sound source object where the radius of that sphere is equal to the volume of the sound. I want the sphere to actually surround my casting object pretty much like this Gizmo sphere in the picture:
I'm currently trying:
var all = Physics.SphereCastAll(transform.position, volume, transform.up, volume, cullingMask);
foreach(var hit in all)
{
Debug.Log(hit.collider.name);
}
But this is not working correctly for objects that are inside the visual gizmo but under/at the same level of the green sphere (what I'm casting from in this ex) because I'm using transform.up
as the direction for the cast so it's casting the sphere up from my green object. I'm not sure about what direction to use, also not sure about the distance. Since I don't want the sphere to travel or anything...
An end result of how this would be like, is shown in this video.
Again: I want the cast to start from my casting object going outwards by radius, that's it, no traveling cast (no direction, distance, etc)
Any help is appreciated, thanks.
Your answer
Follow this Question
Related Questions
How do you perform a stationary SphereCastAll? 1 Answer
SphereCast not hitting the box bollider correctly 0 Answers
Which is more efficent? SphereCast, SphereCastAll, or OverlapSphere? 1 Answer
How to use correctly a SphereCastAll 2 Answers
Trying to find whether a point is close to the edge of a surface 2 Answers