Physics Scripting
Headers: Core/include/Core/PhysicsWorld.h, Core/include/Core/PhysicsComponents.h
Physics vs Direct Transform
When an entity has a RigidBody and Collider, the physics engine (Jolt) controls its position. Modifying Transform.position directly will fight the physics simulation. Instead, use velocity:
Setting Velocity
Full Velocity
Sets all three axes. Overwrites any existing velocity including gravity:
Horizontal Velocity Only
Sets X and Z but preserves the Y velocity (gravity/jumping):
Use SetHorizontalVelocity for character controllers. It lets you control movement on the ground plane without interfering with falling or jumping.
Physics API Reference
RigidBody Component
Controls how the physics engine treats an entity:
Body Types
Collider Component
Defines the collision shape:
Example: Physics Player Controller
Freeze rotation axes on player characters to prevent them from tipping over. In the Inspector, enable Freeze Rotation X and Freeze Rotation Z on the RigidBody component.