-
Notifications
You must be signed in to change notification settings - Fork 8
Sensory
-
ISensorfor general event-driven collision awareness. -
IRadarfor fast, lightweight proximity checks. -
ICollisionRadarfor precise, mask-based collision needs.
implement(self, IRadar);
radar = {
radius: 300,
target_types: [StatefulObject],
on_enter: function(_collision) { ... }
};-
Enemy AI: Detect when a player or NPC enters a guard’s detection zone (
on_enter) and trigger pursuit. -
Stealth Mechanics: Use
detail_modeto know exactly how close the player is and raise alerts gradually. - Power-ups or Collectibles: Detect when the player comes within range to highlight or attract items.
- Multiplayer/Allies: Show nearby teammates on a minimap or radar UI.
- Environmental Hazards: Trigger traps, turrets, or alarms when an object enters a danger zone.
Each sensor is enriched with default properties:
-
is_enabled(bool): Whether the sensor is active. Default:true. -
detail_mode(bool): Whether to store rich collision data or just IDs. Default:true. -
interval(number): Update interval (steps between checks). Default:5. -
radius(number): Detection radius. Default:30. -
offset(array [x,y]): Position offset relative to the instance. Default:[0, 0]. -
target_instances(array): Specific instances to detect. -
target_types(array): Object types to detect.
And there are a view more for ICollisionRadar:
-
exclude_myself(bool): Whether the radar should ignore its own instance during detection. Default:true. -
precise_collision_masks(bool):
If enabled, collisions use precise sprite masks (pixel-perfect).
If disabled, bounding boxes are used.
Default:false. -
order_instances(bool): Whether detected instances should be ordered by distance in the result list. Default:false.
Sensors can define these optional callbacks for custom behavior:
-
on_enter(_collision)→ Runs when a new collision is detected. -
on_step(_collision)→ Runs each update while a collision persists. -
on_leave(_collision)→ Runs when a collision ends.
When a sensor or radar detects a collision, it can return detailed information in a structured format if detail_mode is enabled. These structs typically include the following fields:
-
**
other_instThe ID of the other instance that was detected by the sensor or radar. -
distance_to_other(number)
The distance between the sensor’s center and the detected instance. -
distance_to_border(number)
The distance from the detected instance to the edge of the sensor or radar radius (calculated asradius - distance_to_other).
flowchart LR
A[Start Sensor Check] --> C{Sensor Enabled?}
C -- No --> R[Skip]
C -- Yes --> D[Perform Collision Check]
D --> E{Collision Detected?}
E -- No --> L[on_leave]
E -- Yes --> F{New Collision?}
F -- Yes --> G[on_enter]
F -- No --> H[on_step]
G --> U[Repeat check]
H --> U
L --> U
U --> A
Raptor free: Animation ● StateMachine ● Files(Sync) ● Macros ● Logger ● Controllers ● LG Localization ● Particle Effects ● Tools, other Objects and Helpers
Raptor pro: RACE (The Random Content Engine) ● Savegame System ● UI Subsystem ● Shaders ● Files(Async) ● RichJson ● Scriptor
Back to Repo ● Wiki Home ● Copyright © coldrock.games
- Home
- Working with raptor
- Create a Game
- raptor's object model
- Macros
- Logger
- Controllers
- StateMachine
- Animation
- Particle Effects
- LG Localization
- Interfaces
- Tools, other Objects and Helpers
Raptor Pro Modules