Player's position is reset when close to ghosts

This commit is contained in:
five-hundred-eleven
2025-08-03 11:15:54 -04:00
parent 4aee63a4d3
commit faf3f239d8
12 changed files with 268 additions and 20 deletions

View File

@@ -111,3 +111,15 @@ float rand_float(float rmin, float rmax) {
glm::vec3 Ghost::get_pos() const {
return pos;
}
void Ghost::reverse_direction_from_position(glm::vec3 target_pos) {
// Calculate direction from target_pos to ghost position
glm::vec3 direction = pos - target_pos;
// Set yawr to point directly away from target_pos
yawr = atan2(direction.x, direction.z);
}
void Ghost::regenerate_position() {
pos.x = rand_float(xmin, xmax);
pos.z = rand_float(zmin, zmax);
}