29 lines
717 B
C++
29 lines
717 B
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "GameCamera.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
GameCamera::GameCamera(SceneItem *i) : SceneItemComponent(i) {}
|
|
|
|
std::vector<SceneItemComponent*> GameCamera::getDependencies() {
|
|
return {
|
|
(this->camera = item->getComponent<Camera>())
|
|
};
|
|
}
|
|
|
|
void GameCamera::onStart() {
|
|
assertNotNull(this->camera);
|
|
assertNotNull(this->player);
|
|
|
|
useEvent([&](float_t delta) {
|
|
glm::vec3 cameraTarget = player->transform->getLocalPosition();
|
|
camera->transform->lookAt(
|
|
cameraTarget + glm::vec3(0, 10.0f, 1.5f),
|
|
cameraTarget
|
|
);
|
|
}, getScene()->eventSceneUpdate);
|
|
} |