diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 3f5921a6bb..b4c32805b5 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -298,6 +298,7 @@ void PhysicsEngine::stepSimulation() { _clock.reset(); float timeStep = btMin(dt, MAX_TIMESTEP); + _avatarData->lockForRead(); if (_avatarData->isPhysicsEnabled()) { // update character controller glm::quat rotation = _avatarData->getOrientation(); @@ -307,6 +308,7 @@ void PhysicsEngine::stepSimulation() { btVector3 walkVelocity = glmToBullet(_avatarData->getVelocity()); _characterController->setVelocityForTimeInterval(walkVelocity, timeStep); } + _avatarData->unlock(); // This is step (2). int numSubsteps = _dynamicsWorld->stepSimulation(timeStep, MAX_NUM_SUBSTEPS, PHYSICS_ENGINE_FIXED_SUBSTEP); @@ -342,7 +344,6 @@ void PhysicsEngine::stepSimulation() { } unlock(); - _avatarData->unlock(); _entityTree->unlock(); computeCollisionEvents();