Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(physics): a 3D character can shove what it walks into

esengined225b2710694
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4c4760659..75abd56ee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,11 @@ published separately; it ships inside the editor.
### Added
+- **A 3D character can shove what it walks into.** `CharacterController3D` gained
+ `pushForce` — the force it may spend moving a dynamic body out of its way. A
+ character is swept rather than solved, so nothing moved for it before: `mass`
+ was carried into the solver and had no effect anyone could see.
+
- **Joints for the 3D world.** `PointJoint3D`, `HingeJoint3D`, `SliderJoint3D`,
`DistanceJoint3D` and `FixedJoint3D` — a shared point, an axis to turn about,
an axis to slide along, a distance to keep, and no freedom at all. A door, a
diff --git a/docs/astro/src/content/docs/gameplay/physics-3d.mdx b/docs/astro/src/content/docs/gameplay/physics-3d.mdx
index cc5df6102..88b4ebfec 100644
--- a/docs/astro/src/content/docs/gameplay/physics-3d.mdx
+++ b/docs/astro/src/content/docs/gameplay/physics-3d.mdx
@@ -105,6 +105,7 @@ if (input.justPressed('jump') && c.isOnFloor) c.velocity.y = 500;
| `stepHeight` | Tallest step it climbs instead of stopping at. `0` climbs nothing. |
| `snapDown` | How far it reaches down to stay on the floor over a crest. `0` is off. |
| `maxSlope` | Steepest ground it can stand on; beyond this it slides. |
+| `pushForce` | How hard it shoves dynamic bodies it walks into. `0` moves nothing. |
| `isOnFloor` / `floorNormal` / `realVelocity` | Outputs, read after the step. |
<Aside>
@@ -112,6 +113,11 @@ if (input.justPressed('jump') && c.isOnFloor) c.velocity.y = 500;
"hang in the air". A character does not fall on its own in Jolt — the vertical
speed belongs to the caller — so the module integrates gravity rather than
leaving every caller to rediscover it.
+
+ A character is SWEPT rather than solved, so nothing moves out of its way on its
+ own: `pushForce` is the force it may spend shoving what it walks into. The
+ default gets a crate of its own size going; something heavier wants more, and
+ `0` walks into everything as if it were a wall.
</Aside>
## Joints
diff --git a/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx b/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx
index 3f10fec4a..69e904f9c 100644
--- a/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx
+++ b/docs/astro/src/content/docs/zh-cn/gameplay/physics-3d.mdx
@@ -95,12 +95,17 @@ if (input.justPressed('jump') && c.isOnFloor) c.velocity.y = 500;
| `stepHeight` | 能迈上去而不是被挡住的最高台阶。`0` 就什么都迈不上。 |
| `snapDown` | 过坡顶时向下够多远以贴住地面。`0` 是关掉。 |
| `maxSlope` | 能站住的最陡地面;比这更陡就会滑下去。 |
+| `pushForce` | 撞上动态刚体时能推多用力。`0` 什么都推不动。 |
| `isOnFloor` / `floorNormal` / `realVelocity` | 输出,步进之后读。 |
<Aside>
垂直分量由引擎替你维护:`velocity.y = 0` 的意思是「走」,不是「悬在空中」。
在 Jolt 里角色**不会自己下落**——垂直速度属于调用者——所以这一层替你积分重力,
而不是让每个调用者各自重新发现这件事。
+
+ 角色是被**扫掠**的而不是被求解的,所以没有任何东西会自己给它让路:`pushForce`
+ 就是它可以花在推东西上的力。默认值足以推动一个和它自己差不多大的箱子;
+ 更重的要给更多,而 `0` 会让它把所有东西都当成墙。
</Aside>
## 关节
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index 06194416c..0e547cef7 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -801,6 +801,14 @@
"range": "≥ 0",
"advanced": true
},
+ {
+ "key": "pushForce",
+ "type": "number",
+ "default": "5000",
+ "doc": "How hard it can shove what it walks into",
+ "range": "≥ 0",
+ "advanced": true
+ },
{
"key": "enabled",
"type": "boolean",
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 25a12fd45..67a53d78c 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -5,7 +5,7 @@ Symbols: 113 public · 65 beta · 1443 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"efd9284ec11052f6"
+"3ca8b8f014ab2cd1"
```
## ANCHOR_AXES — const @experimental
@@ -1870,6 +1870,7 @@ isOnFloor: boolean
layer: number
mass: number
maxSlope: number
+pushForce: number
radius: number
realVelocity: Vec3
snapDown: number
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 106d8d62f..496e398a1 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -5,7 +5,7 @@ Symbols: 113 public · 70 beta · 1462 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"efd9284ec11052f6"
+"3ca8b8f014ab2cd1"
```
## ANCHOR_AXES — const @experimental
@@ -1870,6 +1870,7 @@ isOnFloor: boolean
layer: number
mass: number
maxSlope: number
+pushForce: number
radius: number
realVelocity: Vec3
snapDown: number
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index f19ebc139..8edf014ee 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1865,6 +1865,7 @@ isOnFloor: boolean
layer: number
mass: number
maxSlope: number
+pushForce: number
radius: number
realVelocity: Vec3
snapDown: number
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 7d7ef1068..8590b032c 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1865,6 +1865,7 @@ isOnFloor: boolean
layer: number
mass: number
maxSlope: number
+pushForce: number
radius: number
realVelocity: Vec3
snapDown: number
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 627d0589a..f53ec8424 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1865,6 +1865,7 @@ isOnFloor: boolean
layer: number
mass: number
maxSlope: number
+pushForce: number
radius: number
realVelocity: Vec3
snapDown: number
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index 6c45e2cb6..8de5ebc6f 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -381,6 +381,7 @@ export interface CharacterController3DPtrData {
stepHeight: number;
snapDown: number;
mass: number;
+ pushForce: number;
enabled: boolean;
layer: number;
isOnFloor: boolean;
@@ -399,11 +400,12 @@ export function fillCharacterController3D(
out.stepHeight = f32[(ptr + 24) >> 2];
out.snapDown = f32[(ptr + 28) >> 2];
out.mass = f32[(ptr + 32) >> 2];
- out.enabled = u8[ptr + 36] !== 0;
- out.layer = u32[(ptr + 40) >> 2];
- out.isOnFloor = u8[ptr + 44] !== 0;
- const floorNormal_ = out.floorNormal; floorNormal_.x = f32[(ptr + 48) >> 2]; floorNormal_.y = f32[((ptr + 48) >> 2) + 1]; floorNormal_.z = f32[((ptr + 48) >> 2) + 2];
- const realVelocity_ = out.realVelocity; realVelocity_.x = f32[(ptr + 60) >> 2]; realVelocity_.y = f32[((ptr + 60) >> 2) + 1]; realVelocity_.z = f32[((ptr + 60) >> 2) + 2];
+ out.pushForce = f32[(ptr + 36) >> 2];
+ out.enabled = u8[ptr + 40] !== 0;
+ out.layer = u32[(ptr + 44) >> 2];
+ out.isOnFloor = u8[ptr + 48] !== 0;
+ const floorNormal_ = out.floorNormal; floorNormal_.x = f32[(ptr + 52) >> 2]; floorNormal_.y = f32[((ptr + 52) >> 2) + 1]; floorNormal_.z = f32[((ptr + 52) >> 2) + 2];
+ const realVelocity_ = out.realVelocity; realVelocity_.x = f32[(ptr + 64) >> 2]; realVelocity_.y = f32[((ptr + 64) >> 2) + 1]; realVelocity_.z = f32[((ptr + 64) >> 2) + 2];
}
export function writeCharacterController3D(
@@ -417,11 +419,12 @@ export function writeCharacterController3D(
f32[(ptr + 24) >> 2] = data.stepHeight;
f32[(ptr + 28) >> 2] = data.snapDown;
f32[(ptr + 32) >> 2] = data.mass;
- u8[ptr + 36] = data.enabled ? 1 : 0;
- u32[(ptr + 40) >> 2] = data.layer;
- u8[ptr + 44] = data.isOnFloor ? 1 : 0;
- f32[(ptr + 48) >> 2] = data.floorNormal.x; f32[((ptr + 48) >> 2) + 1] = data.floorNormal.y; f32[((ptr + 48) >> 2) + 2] = data.floorNormal.z;
- f32[(ptr + 60) >> 2] = data.realVelocity.x; f32[((ptr + 60) >> 2) + 1] = data.realVelocity.y; f32[((ptr + 60) >> 2) + 2] = data.realVelocity.z;
+ f32[(ptr + 36) >> 2] = data.pushForce;
+ u8[ptr + 40] = data.enabled ? 1 : 0;
+ u32[(ptr + 44) >> 2] = data.layer;
+ u8[ptr + 48] = data.isOnFloor ? 1 : 0;
+ f32[(ptr + 52) >> 2] = data.floorNormal.x; f32[((ptr + 52) >> 2) + 1] = data.floorNormal.y; f32[((ptr + 52) >> 2) + 2] = data.floorNormal.z;
+ f32[(ptr + 64) >> 2] = data.realVelocity.x; f32[((ptr + 64) >> 2) + 1] = data.realVelocity.y; f32[((ptr + 64) >> 2) + 2] = data.realVelocity.z;
}
export function createCharacterController3DData(): CharacterController3DPtrData {
@@ -433,6 +436,7 @@ export function createCharacterController3DData(): CharacterController3DPtrData
stepHeight: 0,
snapDown: 0,
mass: 0,
+ pushForce: 0,
enabled: false,
layer: 0,
isOnFloor: false,
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index 715a63ea1..b859a77d5 100644
--- a/sdk/src/ecs/component.generated.ts
+++ b/sdk/src/ecs/component.generated.ts
@@ -15,7 +15,7 @@ import type { Dimension, Padding } from '../wasm/wasm.generated';
* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to
* run on mismatch, because mismatched offsets read the wrong heap bytes.
*/
-export const ABI_LAYOUT_HASH = 'efd9284ec11052f6';
+export const ABI_LAYOUT_HASH = '3ca8b8f014ab2cd1';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -251,6 +251,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
stepHeight: 0.4,
snapDown: 0.5,
mass: 70,
+ pushForce: 5000,
enabled: true,
layer: 0,
isOnFloor: false,
@@ -268,6 +269,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
stepHeight: { min: 0, advanced: true },
snapDown: { min: 0, advanced: true },
mass: { min: 0, advanced: true },
+ pushForce: { min: 0, advanced: true },
layer: { min: 0, max: 15, advanced: true },
isOnFloor: { advanced: true },
floorNormal: { advanced: true },
@@ -1103,6 +1105,7 @@ export interface CharacterController3DData {
stepHeight: number;
snapDown: number;
mass: number;
+ pushForce: number;
enabled: boolean;
layer: number;
isOnFloor: boolean;
diff --git a/sdk/src/physics3d/Physics3DComponents.ts b/sdk/src/physics3d/Physics3DComponents.ts
index 1d71d75a1..1843d0b0b 100644
--- a/sdk/src/physics3d/Physics3DComponents.ts
+++ b/sdk/src/physics3d/Physics3DComponents.ts
@@ -90,6 +90,7 @@ export const CharacterController3D = defineBuiltin<CharacterController3DData>(
stepHeight: 0.4,
snapDown: 0.5,
mass: 70,
+ pushForce: 5000,
enabled: true,
isOnFloor: false,
floorNormal: { x: 0, y: 0, z: 0 },
@@ -101,6 +102,8 @@ export const CharacterController3D = defineBuiltin<CharacterController3DData>(
stepHeight: { min: 0, step: 0.05, advanced: true },
snapDown: { min: 0, step: 0.05, advanced: true },
mass: { min: 0, advanced: true },
+ pushForce: { min: 0, advanced: true,
+ tooltip: 'How hard it can shove what it walks into' },
layer: { min: 0, max: 15, step: 1, advanced: true },
isOnFloor: { advanced: true },
floorNormal: { advanced: true },
diff --git a/sdk/src/physics3d/Physics3DModule.ts b/sdk/src/physics3d/Physics3DModule.ts
index a05a0415c..a09fac305 100644
--- a/sdk/src/physics3d/Physics3DModule.ts
+++ b/sdk/src/physics3d/Physics3DModule.ts
@@ -54,7 +54,8 @@ export interface Physics3DWasmModule {
_physics3d_addCharacter(entity: number, radius: number, halfHeight: number,
px: number, py: number, pz: number,
- maxSlope: number, mass: number, layer: number): number;
+ maxSlope: number, mass: number, layer: number,
+ pushForce: number): number;
_physics3d_removeCharacter(characterId: number): void;
_physics3d_moveCharacter(characterId: number, vx: number, vy: number, vz: number,
dt: number, stepUp: number, stepDown: number): void;
diff --git a/sdk/src/physics3d/Physics3DSystem.ts b/sdk/src/physics3d/Physics3DSystem.ts
index b7bcd9359..b46bedc5a 100644
--- a/sdk/src/physics3d/Physics3DSystem.ts
+++ b/sdk/src/physics3d/Physics3DSystem.ts
@@ -77,7 +77,7 @@ function moveCharacters(app: App, module: Physics3DWasmModule, characters: BodyM
id = module._physics3d_addCharacter(
entity as number, character.radius / ppu, character.halfHeight / ppu,
p.x / ppu, p.y / ppu, p.z / ppu, character.maxSlope, character.mass,
- character.layer);
+ character.layer, character.pushForce);
if (id === 0) continue;
characters.set(entity, id);
}
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index 09e6d112a..024833e31 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -128,11 +128,12 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
{ name: 'stepHeight', type: 'f32', offset: 24 },
{ name: 'snapDown', type: 'f32', offset: 28 },
{ name: 'mass', type: 'f32', offset: 32 },
- { name: 'enabled', type: 'bool', offset: 36 },
- { name: 'layer', type: 'u32', offset: 40 },
- { name: 'isOnFloor', type: 'bool', offset: 44 },
- { name: 'floorNormal', type: 'vec3', offset: 48 },
- { name: 'realVelocity', type: 'vec3', offset: 60 },
+ { name: 'pushForce', type: 'f32', offset: 36 },
+ { name: 'enabled', type: 'bool', offset: 40 },
+ { name: 'layer', type: 'u32', offset: 44 },
+ { name: 'isOnFloor', type: 'bool', offset: 48 },
+ { name: 'floorNormal', type: 'vec3', offset: 52 },
+ { name: 'realVelocity', type: 'vec3', offset: 64 },
],
},
CircleCollider: {
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 8dfacd341..c9c7d2a45 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -304,6 +304,7 @@ export interface CharacterController3D {
stepHeight: number;
snapDown: number;
mass: number;
+ pushForce: number;
enabled: boolean;
layer: number;
isOnFloor: boolean;
diff --git a/sdk/tests/physics3d-ecs.test.ts b/sdk/tests/physics3d-ecs.test.ts
index 46982e786..e9db94dd6 100644
--- a/sdk/tests/physics3d-ecs.test.ts
+++ b/sdk/tests/physics3d-ecs.test.ts
@@ -270,6 +270,9 @@ describe('the 3D world and the ECS', () => {
expect(added!.args[1]).toBeCloseTo(0.3, 6); // 30 world units = 0.3m
expect(added!.args[2]).toBeCloseTo(0.5, 6);
expect(added!.args[4]).toBeCloseTo(5, 6); // standing 5m up
+ // Push force is a force, not a length: it crosses unscaled, and a character
+ // that never forwarded it walks through crates without moving them.
+ expect(added!.args[9]).toBe(5000);
const [moved] = called('moveCharacter');
expect(moved!.args[1]).toBeCloseTo(2, 6); // 200 units/s = 2 m/s
expect(characters.size).toBe(1);
diff --git a/sdk/tests/physics3d-smoke.mjs b/sdk/tests/physics3d-smoke.mjs
index 0bccae560..f2fa9256d 100644
--- a/sdk/tests/physics3d-smoke.mjs
+++ b/sdk/tests/physics3d-smoke.mjs
@@ -175,7 +175,7 @@ function moveCharacter(id, vx, vy, vz, steps = 1, stepUp = 0.4, stepDown = 0.5)
// Dropped from 3m onto the floor: a capsule of radius 0.3 + half-height 0.5
// stands with its centre 0.8 up, and reports the ground it is on.
-const hero = m._physics3d_addCharacter(9, 0.3, 0.5, -20, 3, 0, 0.87, 70, 0);
+const hero = m._physics3d_addCharacter(9, 0.3, 0.5, -20, 3, 0, 0.87, 70, 0, 5000);
check('a character is handed back', hero !== 0, `id=${hero}`);
const airborne = moveCharacter(hero, 0, 0, 0, 1);
check('and starts in the air', airborne.ground === IN_AIR, `state=${airborne.ground}`);
@@ -212,6 +212,32 @@ check('a wall stops a character', blocked.x < wallX - 0.2,
check('and it did not climb the wall', blocked.y < climbed.y + 0.3,
`y=${blocked.y.toFixed(4)}`);
+// ★ Pushing a crate, as two runs of the same setup. A swept character does not
+// solve against the world, so nothing moves out of its way unless it is given
+// the strength to move it — and `mass` alone never was that.
+const CRATE_STRONG = 12, CRATE_WEAK = 13;
+const strongCrate = m._physics3d_addBox(CRATE_STRONG, 0.2, 0.2, 0.2, -38.5, 0.2, 10,
+ ...IDENTITY, ...FREE(DYNAMIC), 0.2, 0, 0);
+const weakCrate = m._physics3d_addBox(CRATE_WEAK, 0.2, 0.2, 0.2, -38.5, 0.2, 20,
+ ...IDENTITY, ...FREE(DYNAMIC), 0.2, 0, 0);
+const strongHero = m._physics3d_addCharacter(14, 0.3, 0.5, -40, 0.8, 10, 0.87, 70, 0, 6000);
+const weakHero = m._physics3d_addCharacter(15, 0.3, 0.5, -40, 0.8, 20, 0.87, 70, 0, 0);
+m._physics3d_optimize();
+for (let i = 0; i < 150; i++) {
+ m._physics3d_moveCharacter(strongHero, 2, 0, 0, 1 / 60, 0.4, 0.5);
+ m._physics3d_moveCharacter(weakHero, 2, 0, 0, 1 / 60, 0.4, 0.5);
+ m._physics3d_step(1 / 60, 1);
+}
+const shoved = bodyState(strongCrate);
+const unmoved = bodyState(weakCrate);
+check('a character shoves a crate out of its way', shoved && shoved.x > -38.0,
+ `x=${shoved?.x.toFixed(3)} from -38.5`);
+check('and one with no push force does not', unmoved && unmoved.x < -38.35,
+ `x=${unmoved?.x.toFixed(3)} from -38.5`);
+
+m._physics3d_removeCharacter(strongHero);
+m._physics3d_removeCharacter(weakHero);
+
m._physics3d_removeCharacter(hero);
check('a removed character can no longer be moved',
(m._physics3d_moveCharacter(hero, 1, 0, 0, 1 / 60, 0.4, 0.5),
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 934d3bef3..3fdf3186b 100644
--- a/src/esengine/bindings/EditorAPI.generated.cpp
+++ b/src/esengine/bindings/EditorAPI.generated.cpp
@@ -2,10 +2,10 @@
* @file EditorAPI.generated.cpp
* @brief Auto-generated editor API with string-dispatched component access
* @details Generated by EHT - DO NOT EDIT
- * @schema_hash 82e78d440d228f27
+ * @schema_hash 408785a144c7d207
*/
-#define ES_EDITOR_API_SCHEMA_HASH "82e78d440d228f27"
+#define ES_EDITOR_API_SCHEMA_HASH "408785a144c7d207"
#include <emscripten/bind.h>
#include <string>
@@ -206,6 +206,7 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"stepHeight","type":"float","group":"CharacterController3D"},
{"key":"snapDown","type":"float","group":"CharacterController3D"},
{"key":"mass","type":"float","group":"CharacterController3D"},
+ {"key":"pushForce","type":"float","group":"CharacterController3D"},
{"key":"enabled","type":"bool","group":"CharacterController3D"},
{"key":"layer","type":"int","group":"CharacterController3D"},
{"key":"isOnFloor","type":"bool","group":"CharacterController3D"},
@@ -1065,6 +1066,7 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
else if (field == "stepHeight") { c.stepHeight = value; }
else if (field == "snapDown") { c.snapDown = value; }
else if (field == "mass") { c.mass = value; }
+ else if (field == "pushForce") { c.pushForce = value; }
else if (field == "floorNormal.x") { c.floorNormal.x = value; }
else if (field == "floorNormal.y") { c.floorNormal.y = value; }
else if (field == "floorNormal.z") { c.floorNormal.z = value; }
@@ -1522,6 +1524,7 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
else if (field == "stepHeight") { return c.stepHeight; }
else if (field == "snapDown") { return c.snapDown; }
else if (field == "mass") { return c.mass; }
+ else if (field == "pushForce") { return c.pushForce; }
else if (field == "floorNormal.x") { return c.floorNormal.x; }
else if (field == "floorNormal.y") { return c.floorNormal.y; }
else if (field == "floorNormal.z") { return c.floorNormal.z; }
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index 1bdab0de1..0f21a4547 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -1335,6 +1335,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
.field("stepHeight", &esengine::ecs::CharacterController3D::stepHeight)
.field("snapDown", &esengine::ecs::CharacterController3D::snapDown)
.field("mass", &esengine::ecs::CharacterController3D::mass)
+ .field("pushForce", &esengine::ecs::CharacterController3D::pushForce)
.field("enabled", &esengine::ecs::CharacterController3D::enabled)
.field("layer", &esengine::ecs::CharacterController3D::layer)
.field("isOnFloor", &esengine::ecs::CharacterController3D::isOnFloor)
@@ -2664,11 +2665,12 @@ static_assert(offsetof(esengine::ecs::CharacterController3D, maxSlope) == 20, "A
static_assert(offsetof(esengine::ecs::CharacterController3D, stepHeight) == 24, "ABI offset drift: esengine::ecs::CharacterController3D.stepHeight (EHT expected 24)");
static_assert(offsetof(esengine::ecs::CharacterController3D, snapDown) == 28, "ABI offset drift: esengine::ecs::CharacterController3D.snapDown (EHT expected 28)");
static_assert(offsetof(esengine::ecs::CharacterController3D, mass) == 32, "ABI offset drift: esengine::ecs::CharacterController3D.mass (EHT expected 32)");
-static_assert(offsetof(esengine::ecs::CharacterController3D, enabled) == 36, "ABI offset drift: esengine::ecs::CharacterController3D.enabled (EHT expected 36)");
-static_assert(offsetof(esengine::ecs::CharacterController3D, layer) == 40, "ABI offset drift: esengine::ecs::CharacterController3D.layer (EHT expected 40)");
-static_assert(offsetof(esengine::ecs::CharacterController3D, isOnFloor) == 44, "ABI offset drift: esengine::ecs::CharacterController3D.isOnFloor (EHT expected 44)");
-static_assert(offsetof(esengine::ecs::CharacterController3D, floorNormal) == 48, "ABI offset drift: esengine::ecs::CharacterController3D.floorNormal (EHT expected 48)");
-static_assert(offsetof(esengine::ecs::CharacterController3D, realVelocity) == 60, "ABI offset drift: esengine::ecs::CharacterController3D.realVelocity (EHT expected 60)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, pushForce) == 36, "ABI offset drift: esengine::ecs::CharacterController3D.pushForce (EHT expected 36)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, enabled) == 40, "ABI offset drift: esengine::ecs::CharacterController3D.enabled (EHT expected 40)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, layer) == 44, "ABI offset drift: esengine::ecs::CharacterController3D.layer (EHT expected 44)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, isOnFloor) == 48, "ABI offset drift: esengine::ecs::CharacterController3D.isOnFloor (EHT expected 48)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, floorNormal) == 52, "ABI offset drift: esengine::ecs::CharacterController3D.floorNormal (EHT expected 52)");
+static_assert(offsetof(esengine::ecs::CharacterController3D, realVelocity) == 64, "ABI offset drift: esengine::ecs::CharacterController3D.realVelocity (EHT expected 64)");
static_assert(offsetof(esengine::ecs::CircleCollider, radius) == 0, "ABI offset drift: esengine::ecs::CircleCollider.radius (EHT expected 0)");
static_assert(offsetof(esengine::ecs::CircleCollider, offset) == 4, "ABI offset drift: esengine::ecs::CircleCollider.offset (EHT expected 4)");
static_assert(offsetof(esengine::ecs::CircleCollider, density) == 12, "ABI offset drift: esengine::ecs::CircleCollider.density (EHT expected 12)");
@@ -2943,7 +2945,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "efd9284ec11052f6";
+static const char* kEsAbiLayoutHash = "3ca8b8f014ab2cd1";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp
index 64348abbb..486eec75c 100644
--- a/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp
+++ b/src/esengine/bindings/modules/physics3d/Physics3DModuleEntry.cpp
@@ -424,12 +424,15 @@ int physics3d_getBodyState(uint32_t bodyId) {
EMSCRIPTEN_KEEPALIVE
uint32_t physics3d_addCharacter(uint32_t entity, float radius, float halfHeight,
float px, float py, float pz, float maxSlope, float mass,
- uint32_t layer) {
+ uint32_t layer, float pushForce) {
if (!g().isValid()) return 0;
Ref<CharacterVirtualSettings> settings = new CharacterVirtualSettings();
settings->mShape = new CapsuleShape(halfHeight, radius);
settings->mMaxSlopeAngle = maxSlope;
settings->mMass = mass;
+ // Nothing gets out of a swept character's way on its own: this is the force
+ // it may spend shoving what it walks into.
+ settings->mMaxStrength = pushForce;
// The plane below which contacts do not hold the character up. Without it a
// contact anywhere on the capsule — including the top — reads as ground.
settings->mSupportingVolume = Plane(Vec3::sAxisY(), -radius);
diff --git a/src/esengine/ecs/components/RigidBody3D.hpp b/src/esengine/ecs/components/RigidBody3D.hpp
index 5a1bf58b0..a3a2151df 100644
--- a/src/esengine/ecs/components/RigidBody3D.hpp
+++ b/src/esengine/ecs/components/RigidBody3D.hpp
@@ -194,6 +194,14 @@ struct CharacterController3D {
ES_PROPERTY(min=0, advanced)
f32 mass{70.0f};
+ /** @brief How hard it can shove what it walks into, in newtons. A character is
+ * swept rather than solved, so nothing moves out of its way unless it
+ * is given the strength to move it — and the force a solver needs to
+ * get a crate going is well above the one that would hold it there.
+ * 0 pushes nothing at all. */
+ ES_PROPERTY(min=0, advanced)
+ f32 pushForce{5000.0f};
+
ES_PROPERTY()
bool enabled{true};