Only do physics and collision calculations on the clients side, and only for their own entity.
This commit is contained in:
@@ -17,6 +17,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
EntityAABB& boxA = *boundingBox;
|
EntityAABB& boxA = *boundingBox;
|
||||||
bool everHitTheGround = false;
|
bool everHitTheGround = false;
|
||||||
|
|
||||||
|
if (entity == LocalPlayer) {
|
||||||
auto prevPosIt = m_PrevPositions.find(entity);
|
auto prevPosIt = m_PrevPositions.find(entity);
|
||||||
if (prevPosIt != m_PrevPositions.end()) {
|
if (prevPosIt != m_PrevPositions.end()) {
|
||||||
glm::vec3 size = boxA.Size();
|
glm::vec3 size = boxA.Size();
|
||||||
@@ -118,4 +119,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_PrevPositions[entity] = boxA.Origin();
|
m_PrevPositions[entity] = boxA.Origin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,10 @@ PlayerMovementSystem::~PlayerMovementSystem()
|
|||||||
void PlayerMovementSystem::Update(double dt)
|
void PlayerMovementSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
updateMovementControllers(dt);
|
updateMovementControllers(dt);
|
||||||
if (IsServer) {
|
// Only do physics calculations on client and only for themselves.
|
||||||
for (auto& kv : m_PlayerInputControllers) {
|
if (!IsServer && LocalPlayer.Valid()) {
|
||||||
updateVelocity(kv.first, dt);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (LocalPlayer.Valid()) {
|
|
||||||
updateVelocity(LocalPlayer, dt);
|
updateVelocity(LocalPlayer, dt);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMovementSystem::updateMovementControllers(double dt)
|
void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||||
|
|||||||
Reference in New Issue
Block a user