I'm going through the examples and I tried to understand the script rayperception. I understood that it is drawing the rays around the agent. But I couldn't figure out what it is doing beyond of this. The addVectorOrbs is awaiting a vector but we are giving a list of vectors. But I don't know which information the vectors in the list contains. Can I just use this code to draw the rays? If yes, is there something missing that I should insert?
```csharp
private var whenNeeded : boolean;
function Update(){
if(whenNeeded){
DetectEnemy(transform.position, 20);
}
}
function DetectEnemy(center: Vector3, radius: float) {
var hitColliders = Physics.OverlapSphere(center, radius);
for (var i = 0; i < hitColliders.Length; i++) {
print(hitColliders[i].tag);
// collect information on the hits here
}
}
```
RayPerception.Perceive returns a list of floats, not a list of vectors.
The list of floats goes as follows :
number of detectable objects + 1) floats.number of detectable objects to indicate what type of object is being hit by the rayThis gives #angles x (#detectableObjects + 2)
I am not sure what your code does but it does not draw rays. this code will (I think) print the tag of all the objects around center under a distance of radius. If you think that is relevant information, you can definitely give that to your agent as long as you can encode it into a vector of floats of fixed length.
Hi @Semih67
your javascript code excerpt uses a sphere to detect collisions. However, do not use javascript in Unity, because it is deprecated by now.
For what reason do you want to use raycasts? Maybe add a small drawing or a more detailed description of your use-case.
Maybe have a look at this tutorial if you are new to raycasts:
https://www.youtube.com/watch?v=THnivyG0Mvo
Thank you for the discussion. We are closing this issue due to inactivity. Feel free to reopen it if you鈥檇 like to continue to discussion though.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @Semih67
your javascript code excerpt uses a sphere to detect collisions. However, do not use javascript in Unity, because it is deprecated by now.
For what reason do you want to use raycasts? Maybe add a small drawing or a more detailed description of your use-case.
Maybe have a look at this tutorial if you are new to raycasts:
https://www.youtube.com/watch?v=THnivyG0Mvo