Commit 57107559 authored by Florian Oetke's avatar Florian Oetke
Browse files

rotate entities on movement

parent daa74917
Pipeline #3264 passed with stage
in 2 minutes and 27 seconds
......@@ -71,8 +71,11 @@ namespace phase_shifter::gameplay {
}
}
auto look_dir = move.aim;
if(move.step_time_left > 0.f) {
auto t0 = overshoot(1.f - move.step_time_left / move.step_time, move.overshoot);
look_dir = move.last_step;
auto t0 = overshoot(1.f - move.step_time_left / move.step_time, move.overshoot);
move.step_time_left -= dt.value();
......@@ -81,6 +84,22 @@ namespace phase_shifter::gameplay {
transform.position.x = transform.position.x - move.last_step.x * t0 + move.last_step.x * t1;
transform.position.z = transform.position.z - move.last_step.y * t0 + move.last_step.y * t1;
}
auto look_dir_len = glm::length(look_dir);
if(look_dir_len < 0.001f) {
look_dir = move.last_step;
look_dir_len = glm::length(look_dir);
}
if(look_dir_len > 0.001f) {
look_dir /= look_dir_len;
transform.orientation = glm::normalize(glm::slerp(
transform.orientation,
glm::rotation(glm::vec3{0.f, 0.f, 1.f}, glm::vec3(look_dir.x, 0, look_dir.y)),
std::min(1.f, dt.value() * 4.f * _beat_system.graphic_time_scale())));
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment