feat: added drone sound effect to enemies

This commit is contained in:
Sara 2024-12-12 20:46:21 +01:00
parent 52cd856992
commit 3b94a7e0f3
7 changed files with 44 additions and 4 deletions

View file

@ -20,6 +20,7 @@ void Enemy::_ready() {
timer->start(this->update_interval);
timer->connect("timeout", callable_mp(this, &Enemy::update));
this->target_rotation = this->get_rotation().y;
this->drone_sound = this->get_node<gd::AudioStreamPlayer3D>("%DroneSound");
}
void Enemy::_process(double delta) {
@ -88,7 +89,7 @@ void Enemy::_physics_process(double delta [[maybe_unused]]) {
basis.get_column(0) * motion.x +
basis.get_column(1) * motion.y +
basis.get_column(2) * motion.z
});\
});
this->move_and_slide();
}
@ -98,6 +99,7 @@ void Enemy::damage() {
this->set_collision_layer(0x0);
this->set_process(false);
this->set_physics_process(false);
this->drone_sound->stop();
}
void Enemy::notice_player(Player *player) {

View file

@ -5,6 +5,7 @@
#include "player.hpp"
#include "player_anim_tree.hpp"
#include "utils/godot_macros.hpp"
#include <godot_cpp/classes/audio_stream_player3d.hpp>
#include <godot_cpp/classes/character_body3d.hpp>
#include <godot_cpp/classes/navigation_agent3d.hpp>
namespace gd = godot;
@ -32,7 +33,7 @@ public:
float get_update_interval() const;
private:
int const SHOTS_BEFORE_HIT{0};
float const TURN_SPEED{1.5f};
float const TURN_SPEED{3.f};
float const HIT_ANGLE{.05f};
float const MISS_ANGLE{.2f};
@ -46,6 +47,7 @@ private:
Player *player{nullptr};
gd::NavigationAgent3D *agent{nullptr};
PlayerAnimTree *anim_tree{nullptr};
gd::AudioStreamPlayer3D *drone_sound{nullptr};
};
#endif // !ENEMY_HPP