[ADD] made camera follow the character with lerp
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "camera.h"
|
||||
#include <iostream>
|
||||
#include "../toolbox/toolbox.h"
|
||||
|
||||
namespace entities
|
||||
{
|
||||
@@ -8,7 +10,9 @@ namespace entities
|
||||
{}
|
||||
|
||||
void Camera::Follow(glm::vec3 follow_position) {
|
||||
position.z = follow_position.z + 200;
|
||||
follow_position.z += 100;
|
||||
follow_position.y += 50;
|
||||
position = toolbox::Lerp(position, follow_position, 0.1);
|
||||
}
|
||||
|
||||
void Camera::Move(GLFWwindow* window)
|
||||
@@ -41,9 +45,14 @@ namespace entities
|
||||
{
|
||||
up_down_speed += UP_SPEED;
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||
{
|
||||
up_down_speed -= UP_SPEED;
|
||||
}
|
||||
|
||||
position.x += side_speed;
|
||||
position.z += movement_speed;
|
||||
position.y += up_down_speed;
|
||||
std::cout <<"x= " << position.x <<"\ny= " << position.y << "\nz= " << position.z << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user