diff --git a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts index 00e139c75f..98f379f3dd 100644 --- a/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts +++ b/packages/spatial/src/physics/systems/PhysicsPreTransformSystem.ts @@ -30,7 +30,6 @@ import { ECSState } from '@etherealengine/ecs/src/ECSState' import { getState } from '@etherealengine/hyperflux' import { Vector3_One, Vector3_Zero } from '../../common/constants/MathConstants' -import { SceneComponent } from '../../renderer/components/SceneComponents' import { EntityTreeComponent, getAncestorWithComponent, iterateEntityNode } from '../../transform/components/EntityTree' import { TransformComponent } from '../../transform/components/TransformComponent' import { computeTransformMatrix, isDirty, TransformDirtyUpdateSystem } from '../../transform/systems/TransformSystem' @@ -79,13 +78,13 @@ export const lerpTransformFromRigidbody = (entity: Entity, alpha: number) => { const transform = getComponent(entity, TransformComponent) - const sceneEntity = getAncestorWithComponent(entity, SceneComponent) - const sceneTransform = getComponent(sceneEntity, TransformComponent) - parentMatrixInverse.copy(sceneTransform.matrixWorld).invert() + const rigidBodyEntity = getAncestorWithComponent(entity, RigidBodyComponent) + const rigidBodyTransform = getComponent(rigidBodyEntity, TransformComponent) + parentMatrixInverse.copy(rigidBodyTransform.matrixWorld).invert() localMatrix.compose(position, rotation, Vector3_One).premultiply(parentMatrixInverse) localMatrix.decompose(position, rotation, scale) transform.matrix.compose(position, rotation, transform.scale) - transform.matrixWorld.multiplyMatrices(sceneTransform.matrixWorld, transform.matrix) + transform.matrixWorld.multiplyMatrices(rigidBodyTransform.matrixWorld, transform.matrix) /** set all children dirty deeply, but set this entity to clean */ iterateEntityNode(entity, setDirty)