Skip to content

Commit cf753c7

Browse files
committed
Fix #45 raider get huge position offset when thrown by a rocky
To make the grab animation fit the raider scene entity position must be set to origin, but the raider position component was not updated, which caused a huge offset and actually kicking the raider of the map.
1 parent da0a50a commit cf753c7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/game/system/RockMonsterBehaviorSystem.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,10 @@ export class RockMonsterBehaviorSystem extends AbstractGameSystem {
443443
ecs.removeComponent(entity, HeadingComponent)
444444
behaviorComponent.state = ROCK_MONSTER_BEHAVIOR_STATE.throwMan
445445
const prevScale = raider.sceneEntity.getWorldScale(new Vector3())
446+
const raiderPositionComponent = ecs.getComponents(raider.entity).get(PositionComponent)
446447
sceneEntity.setAnimation(ROCK_MONSTER_ACTIVITY.throwMan, () => {
447-
raider.sceneEntity.getWorldPosition(raider.sceneEntity.position)
448+
raider.sceneEntity.getWorldPosition(raiderPositionComponent.position)
448449
raider.sceneEntity.rotation.copy(sceneEntity.rotation)
449-
const raiderPositionComponent = ecs.getComponents(raider.entity).get(PositionComponent)
450-
raiderPositionComponent.position.copy(raider.sceneEntity.position)
451450
raiderPositionComponent.surface = this.worldMgr.sceneMgr.terrain.getSurfaceFromWorld(raiderPositionComponent.position)
452451
raiderPositionComponent.markDirty()
453452
sceneEntity.depositParent?.remove(raider.sceneEntity)
@@ -470,6 +469,7 @@ export class RockMonsterBehaviorSystem extends AbstractGameSystem {
470469
})
471470
})
472471
raider.sceneEntity.position.copy(new Vector3(0, 0, 4)) // XXX Why is this offset needed?
472+
raiderPositionComponent.position.copy(raider.sceneEntity.position)
473473
raider.sceneEntity.rotation.copy(new Euler(0, Math.PI, 0)) // XXX Why is this rotation needed?
474474
sceneEntity.depositParent?.add(raider.sceneEntity)
475475
const parentScale = new Vector3(1, 1, 1)

0 commit comments

Comments
 (0)