If I understood right, with this code you can find collider just in front of the object. But I must detect any collider any where and by any angle. How can I do it? Can you help me?
Thank you you answer. But my problem is with tha direction parameter. →
static function SphereCast (origin : Vector3, radius : float, direction : Vector3, out hitInfo : RaycastHit, distance : float = Mathf.Infinity, layerMask : int = kDefaultRaycastLayers) : bool
direction The direction into which to sweep the sphere.
My satellite turns around the world, I added small sphere on the fixed point that rotates with world. When the point (the small sphere) in the satellite field of view it will use line renderer with this point until the satellites don’t see the point.
If I write the direction paramater as “transform.forward or transform.right…” it is exact direction, but the satellite could see the point although they are not in the same direction. I hope I could tell the problem
You do know raycast directions can be something other than forward, right and up… right?
To get the direction vector between 2 objects just use this simple formula :
direction = objectB.transform.position - objectA.transform.position;
The raycast function will automatically normalize the vector so just plug it right in
Hello, thank you for your answer. But with this : “direction = objectB.transform.position - objectA.transform.position;” there will always be a line between these objects. (like picture2) I need that: when the fixed point in the view of satellite there would be a line between them, otherwise there will not be a line between them. I will explain it with these pictures :
pic1:
pic2:
I mean, the second picture is not working for my project. There would not be a line between them, when the fixed point in the view of satellite (like picture 1) there must be a line between them.
Are you saying you want to draw lines between the one satellite and all other satellites, but only when the other satellites are within a frontal cone of vision of the satellite, and not obstructed by anything?