fix: enemies detecting player too early
parent
05f84f8f78
commit
f048e97ede
|
@ -66,7 +66,8 @@ void Enemy::update() {
|
|||
|
||||
Enemy::ActionFn Enemy::wait_line_of_sight() {
|
||||
this->set_current_state_name("Guard");
|
||||
if(this->get_global_position().distance_squared_to(this->player->get_global_position()) < this->STAB_RANGE * this->STAB_RANGE)
|
||||
this->anim_tree->set_aim_weapon(false);
|
||||
if(this->can_see_player && this->get_global_position().distance_squared_to(this->player->get_global_position()) < this->STAB_RANGE * this->STAB_RANGE)
|
||||
return (ActionFn)&Enemy::stab;
|
||||
else if(this->can_see_player)
|
||||
return (ActionFn)&Enemy::take_aim;
|
||||
|
@ -191,7 +192,7 @@ void Enemy::update_can_see_player() {
|
|||
gd::Vector3 const target{this->player->get_global_position() + gd::Vector3{0.f, 1.8f, 0.f}};
|
||||
// check if the target is in field of view
|
||||
float const dot{(target - origin).normalized().dot(this->get_global_basis().get_column(2))};
|
||||
if(this->current_action_fn != (ActionFn)&Enemy::chase_player && dot <= 0.2f && target.distance_to(origin) > 4.f) {
|
||||
if(this->current_action_fn != (ActionFn)&Enemy::chase_player && dot <= 0.2f && target.distance_to(origin) > 1.5f * 1.5f) {
|
||||
this->can_see_player = false; // target not in field of view
|
||||
} else {
|
||||
// check if the sightline is obstructed by raycast
|
||||
|
|
Loading…
Reference in New Issue