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.

refactor(gameplay): the hunter's lunge goes

esenginee974951b15e5
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 4da6387a5..a53d920c4 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1603 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1602 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -10919,11 +10919,6 @@ DragPlugin
(app: App, contacts?: readonly Contact3D[]): void
```
-## driveHunterRootMotion — function @experimental
-```
-(world: World): void
-```
-
## editorViewAxes — function @experimental
```
(view: EditorViewData): { x: ScreenAxis; y: ScreenAxis; z: ScreenAxis; }
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 71d8c3445..969c2d2f1 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 89 beta · 1622 experimental · 3 deprecated
+Symbols: 113 public · 89 beta · 1621 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
@@ -11152,11 +11152,6 @@ DragPlugin
(app: App, contacts?: readonly Contact3D[]): void
```
-## driveHunterRootMotion — function @experimental
-```
-(world: World): void
-```
-
## editorViewAxes — function @experimental
```
(view: EditorViewData): { x: ScreenAxis; y: ScreenAxis; z: ScreenAxis; }
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index b66e14180..93dcdb759 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 86 beta · 1602 experimental · 3 deprecated
+Symbols: 113 public · 86 beta · 1601 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -10914,11 +10914,6 @@ DragPlugin
(app: App, contacts?: readonly Contact3D[]): void
```
-## driveHunterRootMotion — function @experimental
-```
-(world: World): void
-```
-
## editorViewAxes — function @experimental
```
(view: EditorViewData): { x: ScreenAxis; y: ScreenAxis; z: ScreenAxis; }
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index 040a47f25..2c64b58bb 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1624 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1623 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -11171,11 +11171,6 @@ DragPlugin
(app: App, contacts?: readonly Contact3D[]): void
```
-## driveHunterRootMotion — function @experimental
-```
-(world: World): void
-```
-
## editorViewAxes — function @experimental
```
(view: EditorViewData): { x: ScreenAxis; y: ScreenAxis; z: ScreenAxis; }
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 6e4f8c644..9c7cd8ace 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 113 public · 84 beta · 1614 experimental · 3 deprecated
+Symbols: 113 public · 84 beta · 1613 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -10942,11 +10942,6 @@ DragPlugin
(app: App, contacts?: readonly Contact3D[]): void
```
-## driveHunterRootMotion — function @experimental
-```
-(world: World): void
-```
-
## editorViewAxes — function @experimental
```
(view: EditorViewData): { x: ScreenAxis; y: ScreenAxis; z: ScreenAxis; }
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 2e3f0cfea..2b2ec5f9a 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -897,7 +897,6 @@ export {
Hunter,
decideHunterState,
huntTargets,
- driveHunterRootMotion,
type HunterData,
type HunterState,
type HunterSituation,
diff --git a/sdk/src/gameplay/GameplayPlugin.ts b/sdk/src/gameplay/GameplayPlugin.ts
index 472ee5ad0..4b6ca2aa7 100644
--- a/sdk/src/gameplay/GameplayPlugin.ts
+++ b/sdk/src/gameplay/GameplayPlugin.ts
@@ -28,7 +28,7 @@ import { AnimatorEvent, type AnimatorEventPayload } from '../animation/animatorE
import { EventReader, EventWriter, type EventWriterInstance } from '../ecs/event';
import { Damage, applyDamage, type DamagePayload } from './Health';
import { MeleeAttacks, resolveMeleeHits } from './MeleeAttack';
-import { huntTargets, driveHunterRootMotion } from './Hunter';
+import { huntTargets } from './Hunter';
import { q } from '../math/quat';
import type { World } from '../ecs/world';
import type { Entity } from '../types';
@@ -318,14 +318,6 @@ export class GameplayPlugin implements Plugin {
{ name: 'ThirdPersonControllerSystem' },
), { runIf: playModeOnly });
- // Last writer before the step, after navigation's steering: a lunge is
- // the animation's to override, and the same rule the player follows.
- app.addSystemToSchedule(Schedule.FixedPreUpdate, defineSystem(
- [],
- () => { driveHunterRootMotion(world); },
- { name: 'HunterRootMotionSystem' },
- ), { runIf: playModeOnly });
-
// After it: what the world allowed. The animator hears this one.
app.addSystemToSchedule(Schedule.FixedPostUpdate, defineSystem(
[Res(Time)],
diff --git a/sdk/src/gameplay/Hunter.ts b/sdk/src/gameplay/Hunter.ts
index 5597160bb..c8c486067 100644
--- a/sdk/src/gameplay/Hunter.ts
+++ b/sdk/src/gameplay/Hunter.ts
@@ -28,10 +28,9 @@ import { Perception, type PerceptionData } from '../ai/perception/components';
import { NavAgent, setNavDestination, stopNavAgent } from '../ai/nav/NavAgent';
import { Animator } from '../animation/Animator';
import type { AnimatorControllerAPI } from '../animation/Animator';
-import { AnimatorRootMotion, type AnimatorRootMotionData } from '../animation/animatorRootMotion';
import { Health, type HealthData } from './Health';
import {
- facingYaw, turnToward, yawQuaternion, yawOfQuaternion, rootMotionVelocity,
+ facingYaw, turnToward, yawQuaternion, yawOfQuaternion,
TPC_SPEED, TPC_GROUNDED,
} from './ThirdPersonController';
@@ -201,24 +200,3 @@ export function huntTargets(
});
}
}
-
-/**
- * Hand a hunter's live root motion to its character controller, as the rate it
- * covers. Last writer before the step, because navigation wrote a steering
- * velocity earlier in the frame and a lunge is the animation's to override.
- */
-export function driveHunterRootMotion(world: World): void {
- for (const entity of world.getEntitiesWithComponents(
- [Hunter, AnimatorRootMotion, CharacterController3D],
- )) {
- const data = world.get(entity, Hunter) as HunterData;
- if (!data.enabled) continue;
- const request = world.get(entity, AnimatorRootMotion) as AnimatorRootMotionData;
- if (!request.active) continue;
- const v = rootMotionVelocity(request.deltaPosition, request.deltaTime);
- world.update(entity, CharacterController3D, (c: CharacterController3DData) => {
- c.velocity.x = v.x;
- c.velocity.z = v.z;
- });
- }
-}
diff --git a/sdk/src/gameplay/index.ts b/sdk/src/gameplay/index.ts
index ccc2da55b..30631f1e6 100644
--- a/sdk/src/gameplay/index.ts
+++ b/sdk/src/gameplay/index.ts
@@ -34,7 +34,6 @@ export {
Hunter,
decideHunterState,
huntTargets,
- driveHunterRootMotion,
type HunterData,
type HunterState,
type HunterSituation,
diff --git a/sdk/tests/hunter.test.ts b/sdk/tests/hunter.test.ts
index 42754e0cb..ae77a4d3f 100644
--- a/sdk/tests/hunter.test.ts
+++ b/sdk/tests/hunter.test.ts
@@ -6,7 +6,7 @@
*/
import { describe, it, expect } from 'vitest';
import {
- Hunter, decideHunterState, huntTargets, driveHunterRootMotion,
+ Hunter, decideHunterState, huntTargets,
TPC_SPEED, TPC_GROUNDED, TPC_ATTACK,
type HunterData,
} from '../src/gameplay';
@@ -14,7 +14,6 @@ import { Health, type HealthData } from '../src/gameplay';
import { Perception, type PerceptionData } from '../src/ai/perception/components';
import { NavAgent, type NavAgentData } from '../src/ai/nav/NavAgent';
import { CharacterController3D, type CharacterController3DData } from '../src/physics3d/Physics3DComponents';
-import { AnimatorRootMotion, type AnimatorRootMotionData } from '../src/animation';
import { Animator, AnimatorControllerAPI, type AnimatorData } from '../src/animation';
import { Transform, type TransformData } from '../src/ecs/component';
import { q } from '../src/math/quat';
@@ -274,32 +273,3 @@ describe('which way a hunter looks', () => {
expect(yawOf(world)).toBeCloseTo(90, 3);
});
});
-
-describe('a hunter’s lunge goes through the character controller', () => {
- it('becomes the rate the animation asked for', () => {
- const world = scene();
- world.insert(ENEMY, AnimatorRootMotion, {
- enabled: true, active: true,
- deltaPosition: { x: 0, y: 0, z: -4 },
- deltaRotation: { w: 1, x: 0, y: 0, z: 0 },
- deltaTime: 1 / 60,
- } as AnimatorRootMotionData);
- driveHunterRootMotion(world);
- expect(body(world).velocity.z).toBeCloseTo(-240, 5);
- });
-
- it('and leaves the steering alone when no animation is driving', () => {
- const world = scene();
- world.insert(ENEMY, AnimatorRootMotion, {
- enabled: true, active: false,
- deltaPosition: { x: 0, y: 0, z: -4 },
- deltaRotation: { w: 1, x: 0, y: 0, z: 0 },
- deltaTime: 1 / 60,
- } as AnimatorRootMotionData);
- world.update(ENEMY, CharacterController3D, (c: CharacterController3DData) => {
- c.velocity.z = -77;
- });
- driveHunterRootMotion(world);
- expect(body(world).velocity.z).toBe(-77);
- });
-});