a6548a72b3
# Conflicts: # include/Engine/Collision/CollidableOctreeSystem.h # include/Engine/Collision/CollisionSystem.h # include/Engine/Collision/TriggerSystem.h # include/Engine/Rendering/RenderSystem.h # include/Game/Systems/PlayerSystem.h # resources/Schema/Components/Physics.xsd # resources/Schema/Types/Entity.xsd # src/Engine/Rendering/RenderSystem.cpp # src/Engine/Rendering/Renderer.cpp # src/Game/Game.cpp # src/Game/Systems/HealthSystem.cpp # src/Game/Systems/PlayerSystem.cpp # src/Tests/OctTreeTestGameClass.cpp
18 lines
533 B
C++
18 lines
533 B
C++
#include "Systems/PlayerMovementSystem.h"
|
|
|
|
void PlayerMovementSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
|
{
|
|
ComponentWrapper& cTransform = entity["Transform"];
|
|
if (!entity.HasComponent("Physics")) {
|
|
return;
|
|
}
|
|
ComponentWrapper& cPhysics = entity["Physics"];
|
|
|
|
glm::vec3& velocity = cPhysics["Velocity"];
|
|
if (cPhysics["Gravity"]) {
|
|
velocity.y -= 9.82 * dt;
|
|
}
|
|
|
|
glm::vec3& position = cTransform["Position"];
|
|
position += velocity * (float)dt;
|
|
} |