Files
Copium/CopiumEngine/src/copium/example/CameraFollowPlayerSystem.h
T
Thraix ca61bae014 Initial editor commit
- Add Entity Tree View used to select entities to be modified
- Add Entity View used to Add/Remove/Edit Components of the Entity
- Add Asset View which lists all available assets
2023-07-18 11:58:55 +02:00

22 lines
593 B
C++

#pragma once
#include "copium/ecs/System.h"
#include "copium/example/Components.h"
namespace Copium
{
class CameraFollowPlayerSystem : public System<PlayerC, TransformC>
{
public:
void RunEntity(Entity entity, PlayerC& player, TransformC& transform) override
{
if (!ValidateEntity<TransformC>(player.camera))
return;
TransformC& cameraTransform = player.camera.GetComponent<TransformC>();
glm::vec2 wantedPos = transform.position + transform.size * 0.5f;
cameraTransform.position -= (cameraTransform.position - wantedPos) * 0.10f;
}
};
}