HurtboxBase can now find a character hit solely from the CharacterSkeleton3D.
This commit is contained in:
@@ -55,18 +55,19 @@ void HurtboxBase::_ready()
|
|||||||
|
|
||||||
void HurtboxBase::_physics_process(double delta)
|
void HurtboxBase::_physics_process(double delta)
|
||||||
{
|
{
|
||||||
TypedArray<Character3D> characters_hit_this_frame;
|
|
||||||
|
|
||||||
const TypedArray<Node3D> &bodies = this->get_overlapping_bodies();
|
const TypedArray<Node3D> &bodies = this->get_overlapping_bodies();
|
||||||
const uint32_t num_bodies = bodies.size();
|
const uint32_t num_bodies = bodies.size();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < num_bodies; i++)
|
for (uint32_t i = 0; i < num_bodies; i++)
|
||||||
{
|
{
|
||||||
if (Character3D *body = cast_to<Character3D>(bodies[i]))
|
if (PhysicalBone3D *character_bone = cast_to<PhysicalBone3D>(bodies[i]))
|
||||||
{
|
{
|
||||||
if (!this->hit_character_bodies.has(body))
|
if (CharacterSkeleton3D *character_skeleton = cast_to<CharacterSkeleton3D>(character_bone->get_owner()))
|
||||||
{
|
{
|
||||||
characters_hit_this_frame.append(body);
|
Character3D *body = cast_to<Character3D>(character_skeleton->get_parent());
|
||||||
|
if (body && !this->hit_character_bodies.has(body))
|
||||||
|
{
|
||||||
|
this->hit_character_bodies.append(body);
|
||||||
TypedArray<int32_t> bone_hits;
|
TypedArray<int32_t> bone_hits;
|
||||||
|
|
||||||
for (uint32_t bone_index = 0; bone_index < num_bodies; bone_index++)
|
for (uint32_t bone_index = 0; bone_index < num_bodies; bone_index++)
|
||||||
@@ -93,8 +94,7 @@ void HurtboxBase::_physics_process(double delta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this->hit_character_bodies.append_array(characters_hit_this_frame);
|
|
||||||
|
|
||||||
if (this->remaining_life <= 0.0f)
|
if (this->remaining_life <= 0.0f)
|
||||||
this->collision_shape->set_disabled(true);
|
this->collision_shape->set_disabled(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user