Actor > Sensor#
Sensors are helper actors that can be attached to another actor to detect nearby objects and interactions.
API Reference#
Sensor#
- class miniworlds.actors.sensors.sensor_actor.Sensor(actor, *args, **kwargs)[source]
An invisible sensor attached to another actor.
A Sensor follows the actor it is attached to and detects nearby objects. The sensor itself is not visible and will never detect the actor it belongs to.
Use actor.register_sensor(Sensor) to attach a sensor to an actor.
- Parameters:
actor – The parent actor this sensor is attached to.
Examples
player = Actor((100, 100)) player.register_sensor(Sensor)
Circle Sensor#
- class miniworlds.actors.sensors.circle_sensor.CircleSensor(actor, distance, **kwargs)[source]
A circular invisible sensor attached to another actor.
CircleSensor creates a circular detection area around the parent actor. Any actor that overlaps with this circle will be detected. The sensor itself is invisible and never detects the parent actor.
Use actor.register_sensor(CircleSensor, distance=<pixels>) to attach it.
- Parameters:
actor – The parent actor this sensor belongs to.
distance – Radius of the circular detection area in pixels.
Examples
player = Actor((100, 100)) player.register_sensor(CircleSensor, distance=50)