implementing a laser range finder


I am new to panda, and I am trying to adapt the Roaming ralph example to implement distance sensors on the Actor. I want the rays to be displayed at all times and I want to record the closest object it intercepts with.

I am trying to use collisionRay for this, but I am not having much luck.

anyone has experience with this? any tips?

I would do it using CollisionSphere (with the required distance as sphere radius). CollisionHandlerQueue would record all intersections, and after sorting them you can get the closest.

Using the collisionsphere is not a solution in my case, because I want to find the distance of obstacles at a variable distance within the range of the distance sensor and not only detect collisions at an specified distance.

CollisionSphere collides with everything that intersects with its surface or is inside of the sphere. I think it’s what you need.
EDIT: If you use CollisionRay then you need to create as many rays as many objects you have on the scene to check if they are within the given distance. Most likely, this is too many.