Skip to content

Commit

Permalink
feat: opt code
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhuang committed Aug 13, 2024
1 parent 1d24986 commit 11fb4fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/physics/CharacterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class CharacterController extends Collider {
*/
move(disp: Vector3, minDist: number, elapsedTime: number): number {
const flags = (<ICharacterController>this._nativeCollider).move(disp, minDist, elapsedTime);
this._getWorldPositionFromBackend();
this._syncWorldPositionFromPhysicalSpace();
return flags;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ export class CharacterController extends Collider {
* @internal
*/
override _onLateUpdate() {
this._getWorldPositionFromBackend();
this._syncWorldPositionFromPhysicalSpace();
this._updateFlag.flag = false;
}

Expand Down Expand Up @@ -166,9 +166,8 @@ export class CharacterController extends Collider {
}
}

private _getWorldPositionFromBackend(): void {
const position = this.entity.transform.worldPosition;
(<ICharacterController>this._nativeCollider).getWorldPosition(position);
private _syncWorldPositionFromPhysicalSpace(): void {
(<ICharacterController>this._nativeCollider).getWorldPosition(this.entity.transform.worldPosition);
}

private _setUpDirection(): void {
Expand Down

0 comments on commit 11fb4fe

Please sign in to comment.