replace near sensor with something else

i need to replace the near sensor for something that doesnt drains the FPS that much as this sensor, what can i do?

I believe the near sensor works based on the physical shape of objects that cross the sensor. So, having simpler meshes should help speed things up.

Otherwise, you could try using Python, as a mathematical distance test wouldn’t take into account the shapes of the individual object meshes, but rather just the distances to their centers, and so should run faster.

The simple python way is to use the ‘obj1.getDistanceTo(obj2)’ function.
Or you can cast a ray, which not only get’s you the distance, but the angle and if there’s something between you and it.

Do a test with a cube and if it’s quicker make an invisible box as a child bounding box, run the sensor on that. You could also try not running the sensor every tick.

i think im going to use python, (what else if not python?)as i think it would be a lot faster
i will try this


as SolarLune and sdfgeoff said

thanks for the help!

I did a test in this blend. Use L and R arrow keys.


near.blend (1.57 MB)