RigidBodyComponent struct in Thread

Makes an entity participate in physics simulation via Jolt. Pair with one of the collider components (Box / Sphere / Capsule) to define the shape — without a collider the body defaults to a 1×1×1 box.

Not on the same entity as a CharacterControllerComponent. The controller has a body of its own, so the pair gives one entity two overlapping bodies and a position the rigid-body pass wins — see that page for what it looks like when it goes wrong. Note the default box above is exactly why removing the collider does not undo it: remove this component.

Properties — authored

IsStaticboolImmovable level geometry. Mutually exclusive with IsKinematic. Default false.
IsKinematicboolMoved by script, ignores forces, pushes dynamic bodies. Default false.
UseGravityboolApply world gravity each step. Default true.
MassfloatIn kg. Default 1.0.
Frictionfloat0..1. Default 0.2.
RestitutionfloatBounciness 0..1. Default 0.0.
LinearDampingfloatTranslation drag. Default 0.05.
AngularDampingfloatRotation drag. Default 0.05.
ConstraintsMotionConstraintsWhich world axes the body may still move on — see below.

Properties — runtime

BodyIduint32_tJolt body handle. 0xFFFFFFFF until Play starts.
AppliedAxesuint8_tWhat the live body was last told its axes were. Not serialized.

Constraints

Six switches, the same as Unity's, and the same meaning: world axes, not the body's own.

FreezePositionX / Y / ZboolThe body may not move along that world axis.
FreezeRotationX / Y / ZboolThe body may not rotate about that world axis.
To stop something toppling, freeze rotation X and Z. Y is left free so it can still be turned, which is what steering is — freezing all three would also stop that. The editor offers this as a one-click Keep Upright, and the MCP tool as upright: true, so the pair cannot be got wrong by hand.
auto& rb = entity.GetComponent<Thread::RigidBodyComponent>();
rb.Constraints = Thread::UprightConstraints();   // cannot tip; can still slide and turn

Constraints apply immediately, including while the game is running: the body is asked for its degrees of freedom when it is created, and the scene re-applies whatever changed after that.

Freezing all six makes the body kinematic. It is not a body with no freedom — Jolt rejects that outright — and it is not what the setting means either. Something no force can move that still goes wherever its transform is put is a kinematic body, so that is what it becomes. If that is what you want, tick IsKinematic and say so.

If a body still tips over with rotation frozen, the cause is almost certainly the pairing warned about at the top of this page: an entity carrying both this and a CharacterController has two overlapping bodies shoving each other apart, and no constraint reaches that.

Driving the body from a script

Use PhysicsSystem:

auto& rb = GetComponent<Thread::RigidBodyComponent>();
Thread::PhysicsSystem::AddImpulse(rb.BodyId, Thread::Vec3(0.0f, 5.0f, 0.0f));   // jump
Thread::PhysicsSystem::SetLinearVel(rb.BodyId, Thread::Vec3(0.0f, 0.0f, -3.0f));// constant push

RigidBodyComponent struct w Thread

Włącza encję do symulacji fizyki w Jolt. Połącz z jednym z komponentów collidera (Box / Sphere / Capsule), który określa kształt — bez collidera ciało dostaje domyślny sześcian 1×1×1.

Nie na tej samej encji co CharacterControllerComponent. Kontroler ma własne ciało, więc para daje jednej encji dwa nachodzące ciała i pozycję, którą wygrywa pass ciał sztywnych — jak to wygląda, gdy idzie źle, opisuje tamta strona. Zauważ, że to przez domyślny sześcian wyżej usunięcie collidera nic nie zmienia: usuń ten komponent.

Właściwości — ustawiane

IsStaticboolNieruchoma geometria poziomu. Wyklucza IsKinematic. Domyślnie false.
IsKinematicboolPrzesuwane skryptem, ignoruje siły, popycha ciała dynamiczne. Domyślnie false.
UseGravityboolDziała na nie grawitacja świata. Domyślnie true.
MassfloatW kg. Domyślnie 1.0.
Frictionfloat0..1. Domyślnie 0.2.
RestitutionfloatSprężystość 0..1. Domyślnie 0.0.
LinearDampingfloatOpór ruchu postępowego. Domyślnie 0.05.
AngularDampingfloatOpór obrotu. Domyślnie 0.05.
ConstraintsMotionConstraintsW których osiach świata ciało może się jeszcze ruszać — patrz niżej.

Właściwości — w czasie działania

BodyIduint32_tUchwyt ciała Jolt. 0xFFFFFFFF do startu Play.
AppliedAxesuint8_tJakie osie ostatnio przekazano żywemu ciału. Nie zapisywane.

Ograniczenia ruchu

Sześć przełączników, jak w Unity, i o tym samym znaczeniu: osie świata, nie własne osie ciała.

FreezePositionX / Y / ZboolCiało nie może się przesuwać wzdłuż tej osi świata.
FreezeRotationX / Y / ZboolCiało nie może się obracać wokół tej osi świata.
Żeby coś się nie przewracało, zablokuj obrót X i Z. Y zostaje wolne, żeby dało się to obracać — tym jest sterowanie; zablokowanie wszystkich trzech zatrzymałoby i to. Edytor daje to jako jednoklikowe Keep Upright, a narzędzie MCP jako upright: true, żeby tej pary nie dało się pomylić ręcznie.
auto& rb = entity.GetComponent<Thread::RigidBodyComponent>();
rb.Constraints = Thread::UprightConstraints();   // nie przewróci się; nadal sunie i się obraca

Ograniczenia działają od razu, także w trakcie gry: ciało pyta o stopnie swobody przy tworzeniu, a scena ponownie stosuje to, co się potem zmieniło.

Zablokowanie wszystkich sześciu czyni ciało kinematycznym. To nie jest ciało bez swobody — Jolt takie odrzuca — i nie to oznacza to ustawienie. Coś, czego żadna siła nie ruszy, a co idzie tam, gdzie postawi je transform, jest ciałem kinematycznym, więc takim się staje. Jeśli o to ci chodzi, zaznacz IsKinematic i powiedz to wprost.

Jeśli ciało nadal się przewraca mimo zablokowanego obrotu, przyczyną jest niemal na pewno para opisana na górze tej strony: encja z tym komponentem i CharacterController ma dwa nachodzące ciała, które się rozpychają, a żadne ograniczenie tego nie dosięga.

Sterowanie ciałem ze skryptu

Użyj PhysicsSystem:

auto& rb = GetComponent<Thread::RigidBodyComponent>();
Thread::PhysicsSystem::AddImpulse(rb.BodyId, Thread::Vec3(0.0f, 5.0f, 0.0f));   // skok
Thread::PhysicsSystem::SetLinearVel(rb.BodyId, Thread::Vec3(0.0f, 0.0f, -3.0f));// stałe pchanie