TriggerComponent struct in Thread
Turns the body into a trigger (a Jolt sensor): it reports what touches it but
pushes nothing — checkpoint volumes, pickup zones, the mouth of a slot. Needs a
RigidBodyComponent and a collider, like any other body.
A script on this entity receives OnTriggerEnter / OnTriggerExit.
Properties
| OnEnterAction | std::string | Named UIAction fired when something enters (optional). |
| OnExitAction | std::string | Named UIAction fired when something leaves (optional). |
| Inside | std::vector<entity> | Runtime — who is in the volume right now (not serialized). |
Static sensors only detect moving bodies — that is Jolt's rule
(two overlapping static zones is not an event). The player works because a
CharacterController carries an inner kinematic
body, so it is visible to triggers, raycasts and overlaps.
Scene queries
Besides triggers, the scene exposes on-demand physics queries you can call from a script:
| CastRay(origin, dir, maxDist) | hit? | Closest body hit along a ray. |
| OverlapSphere(center, radius) | entities | Bodies intersecting a sphere. |
Example
void OnTriggerEnter(Thread::Entity other) override {
if (other.GetComponent<Thread::TagComponent>().Tag == "Player")
Thread::Logger::Info("Player entered the zone");
}
TriggerComponent struct w Thread
Zamienia ciało w trigger (sensor Jolt): zgłasza, co go dotyka, ale niczego nie
odpycha — strefy checkpointów, strefy podnoszenia, wlot automatu. Jak każde ciało potrzebuje
RigidBodyComponent i collidera. Skrypt na tej encji
dostaje OnTriggerEnter / OnTriggerExit.
Właściwości
| OnEnterAction | std::string | Nazwana UIAction wywoływana, gdy coś wejdzie (opcjonalnie). |
| OnExitAction | std::string | Nazwana UIAction wywoływana, gdy coś wyjdzie (opcjonalnie). |
| Inside | std::vector<entity> | W czasie działania — kto jest teraz w strefie (nie zapisywane). |
Statyczne sensory wykrywają tylko ruchome ciała — to reguła Jolt
(dwie nachodzące na siebie statyczne strefy to nie zdarzenie). Gracz działa, bo
CharacterController ma wewnętrzne ciało
kinematyczne, więc widzą go triggery, raycasty i testy nakładania.
Zapytania sceny
Oprócz triggerów scena udostępnia zapytania fizyczne na żądanie, które wywołasz ze skryptu:
| CastRay(origin, dir, maxDist) | trafienie? | Najbliższe ciało trafione promieniem. |
| OverlapSphere(center, radius) | encje | Ciała przecinające sferę. |
Przykład
void OnTriggerEnter(Thread::Entity other) override {
if (other.GetComponent<Thread::TagComponent>().Tag == "Player")
Thread::Logger::Info("Player entered the zone");
}