Hitboxes now send multiple hitboxes per frame instead of just one.

This commit is contained in:
2026-10-02 00:27:32 -04:00
parent 4e0b756000
commit 1a38b7bf19
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -110,14 +110,14 @@ void HurtboxBase::_physics_process(double delta)
void HurtboxBase::_send_next_in_queue() void HurtboxBase::_send_next_in_queue()
{ {
if (!this->hit_data_queue.empty()) for (uint8_t i = 0; i < MAX_HITS_PER_QUEUE_LOOP && !this->hit_data_queue.empty(); i++)
{ {
IDamageable *closest_damageable = nullptr; IDamageable *closest_damageable = nullptr;
float shortest_distance_from_hurtbox = FLT_MAX; float shortest_distance_from_hurtbox = FLT_MAX;
bool found_character_3d = false; bool found_character_3d = false;
for (const auto &[damageable, hit_data_list] : this->hit_data_queue) for (const auto &[damageable, hit_data_list] : this->hit_data_queue)
{ {
if (const Character3D *node = (Character3D*)(damageable)) if (const Character3D *node = cast_to<Character3D>(damageable))
{ {
const float distance_to_hurtbox = node->get_global_position().distance_squared_to(this->get_global_position()); const float distance_to_hurtbox = node->get_global_position().distance_squared_to(this->get_global_position());
if (distance_to_hurtbox < shortest_distance_from_hurtbox) if (distance_to_hurtbox < shortest_distance_from_hurtbox)
+2
View File
@@ -17,6 +17,8 @@
#include <godot_cpp/classes/area3d.hpp> #include <godot_cpp/classes/area3d.hpp>
using namespace godot; using namespace godot;
#define MAX_HITS_PER_QUEUE_LOOP 3
#define HURTBOX_BASE_TAG "HurtboxBase" #define HURTBOX_BASE_TAG "HurtboxBase"