Krotox Engine › Docs › Krotox Manual › 2D Physics
Connecting bodies with Box2D joints (distance, hinge, slider, wheel, weld, motor, target, friction), breakable joints, building ragdolls, and the ready-made gameplay components: spawners, bumpers, force fields, portals, conveyors, hazards, motion paths and level metadata.
A joint connects two bodies and limits how they can move relative to each other. Add the joint component to one entity and set Connected Entity to the other. Both need a Rigidbody 2D.
Fields most joints share:
| Field | Meaning |
|---|---|
Connected Entity | The other body. |
Anchor A / Anchor B | Where the joint attaches on each body, in that body's local space. |
Collide Connected | Whether the two connected bodies still collide with each other. Usually off. |
Enable Break Force / Break Force | Break the joint when it is pulled harder than this (newtons). Default 1000. |
Enable Break Torque / Break Torque | Break it when twisted harder than this. |
| Joint | Keeps | Key fields | Use it for |
|---|---|---|---|
| Distance Joint 2D | A distance between two points | Length (default 1), Auto Length, Enable Spring + Hertz (4) and Damping Ratio (0.5), Enable Limit + Min / Max Length | Ropes, chains, springy connections, swinging lamps. |
| Hinge Joint 2D | A shared pivot point | Enable Limit + Lower / Upper Angle, Enable Motor + Motor Speed and Max Motor Torque, Enable Spring + Target Angle | Doors, pendulums, flippers, ragdoll joints, spinning traps. |
| Slider Joint 2D | Movement along one axis | Axis (default 1, 0), Enable Limit + Lower / Upper Translation, Enable Motor + Motor Speed and Max Motor Force, Enable Spring + Target Translation | Pistons, elevators, sliding doors, rails. |
| Wheel Joint 2D | A wheel on suspension | Axis (default 0, 1), Enable Spring + Hertz and Damping Ratio (0.7), Enable Motor + Motor Speed and Max Motor Torque, Enable Limit | Vehicle wheels. |
| Weld Joint 2D | Both bodies locked together | Linear Hertz, Angular Hertz, Linear / Angular Damping Ratio (0 hertz is fully rigid) | Gluing pieces that can break apart. |
| Motor Joint 2D | One body driven relative to another | Linear Velocity, Angular Velocity, Max Velocity Force / Torque, spring settings | Driving a body toward a pose; moving platforms that carry riders. |
| Target Joint 2D | A point pulled toward a world target | Target, Anchor, Max Force (1000), Hertz (5), Damping Ratio (0.7). No connected entity. | Dragging objects with a finger or the mouse. |
| Friction Joint 2D | Resistance to relative motion | Max Force (50), Max Torque (10) | Top-down games: objects that slide to a stop on the "floor". |
With a break force or torque enabled, the joint snaps when the load passes the threshold, and the script on the entity receives OnJointBreak2D. Scripts can also break a joint on purpose with Break(), and read the live ReactionForce and ReactionTorque.
Motor speed, maximum torque or force, and spring targets can be set from a script every frame. They update the running joint in place, so the motion stays smooth. Enable the motor or spring first (in the inspector or once with SetMotor). See driving joint motors.
If a falling chain jitters, raise Physics Rate in the project settings, then try Contact Softening.
For limbs that should reach a target (a hand toward a ledge, feet on uneven ground), InverseKinematics2D.SolveTwoBone works out the angles from a script; feed them to the hinges' TargetAngle.
Ready-made behaviours that run inside the physics step. Add them from Add Component ▸ Physics Gameplay. They are configured in the inspector and scripts can change them while the game runs.
Force Field Zone, Portal, Hazard Zone and Proximity Trigger read who is inside them from a sensor collider on the same entity: tick Is Sensor or they do nothing. Physics Bumper and Surface Conveyor use solid contacts, so their colliders must not be sensors.
| Component | What it does | Key fields |
|---|---|---|
| Spawner | Releases a prefab on a timer. | Spawn Prefab; Spawn Interval (1 s) with jitter; Max Ammo (-1 = unlimited); Max Simultaneous (0 = unlimited); Launch Velocity with speed and angle jitter; Sweep (horizontal, vertical or circular oscillation); optional charge (an idle spawner fires an over-charged shot) and overheat (heat builds per shot and jams the spawner). |
| Physics Bumper | Kicks bodies that hit it. | Mode: Radial (away from the centre, a pinball bumper) or Directional (along Direction, a launch pad); Impulse Strength (8); Retrigger Delay (0.1 s); Scale Punch (a squash on impact); impact sound. |
| Force Field Zone | Wind or a radial push or pull inside the zone. | Mode: Directional (along Force) or Radial (negative strength pulls in); Ignore Mass (everything accelerates equally, like gravity); Falloff With Distance; Oscillate for gusts. Draws arrows over the zone in the Viewport. |
| Portal | Teleports bodies to a linked portal. | Linked Portal (links are one-way: set the partner's link back for a pair); Reorient Velocity; Preserve Speed; Minimum Entry Speed; Exit Offset; Reentry Cooldown (0.25 s, which stops a pair ping-ponging a body). |
| Surface Conveyor | Carries bodies along its surface. | Surface Speed (3, along the entity's local +X: rotate the entity to rotate the belt); Match Target Velocity; Acceleration; Affect Vertical Axis; Reverse. |
| Hazard Zone | Reacts when something enters. | On Enter: Destroy Entity, Respawn At Start, Reload Scene or Event Only; Target Tag (empty affects everything, which is rarely what you want); Trigger Delay; optional effect prefab and sound. |
| Proximity Trigger | Rewards near misses around a hazard. | Core Hazard (touching it disqualifies the graze); Graze Score (100); Score Multiplier; Award On Exit; Highlight Visitor with a tint. Reports through OnTriggerEnter / OnTriggerExit. |
Runtime state on these components (timers, heat, jams, graze counts) resets when you stop Play.
Moves or rotates an entity on a loop, with no script: moving platforms, swinging blades, rotating obstacles, doors.
| Field | Default | Meaning |
|---|---|---|
Type | Linear Ping Pong | Linear Ping Pong (A to B and back), Linear Loop, Continuous Rotation, Oscillating Swing or Move And Rotate. |
Point A, Point B | — | The two ends of a linear path. |
Easing | Smooth Step | Linear, Ease In Out Quad, Ease In Out Cubic, Smooth Step or Bounce. |
Speed | 2 | Movement speed. |
Pause Duration At Ends | 0.2 s | Wait at each end. |
Rotation Speed | 90 °/s | For the rotating types. |
Swing Angle Min / Max | -45° / 45° | Range of an oscillating swing. |
Phase Offset | 0 | Start partway through, so several platforms move out of step. |
Pivot Offset | — | The hinge for rotating types. Drag the magenta pivot handle in the Viewport. |
The Level Metadata component describes a level: Level Index, Level Name, Chapter Name, Target Score (100), Time Limit Seconds (60), Required Collectibles (3), the Next Level Scene and Auto Load Next On Victory. It also has three star conditions, each with a score, a time and a collectible count:
| Star | Default condition |
|---|---|
| 1 | Complete the level (100 points within 120 s) |
| 2 | Beat the par time (250 points within 60 s, 2 collectibles) |
| 3 | Collect everything (500 points within 45 s, 3 collectibles) |
Edit it inline with Level Data on the toolbar's Level Stepper. Scripts call EvaluateStars(score, elapsed, collectibles) at the end of a level to get 0 to 3 stars.