diff --git a/include/client/Bullet.h b/include/client/Bullet.h index 8a8ab52..c65304e 100644 --- a/include/client/Bullet.h +++ b/include/client/Bullet.h @@ -19,6 +19,8 @@ class Bullet : public godot::Node3D { private: bool m_Stuck; float m_LifeTime; + + void SetTransparency(godot::Node* a_Root, float a_Transparency); }; } // namespace blitz \ No newline at end of file diff --git a/src/client/Bullet.cpp b/src/client/Bullet.cpp index 874a427..c61c0aa 100644 --- a/src/client/Bullet.cpp +++ b/src/client/Bullet.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,9 @@ void Bullet::_process(float a_Delta) { return; } + auto* head = get_node("Armature"); + SetTransparency(head, m_LifeTime / MaxAlive); + if (m_Stuck) return; @@ -49,8 +53,18 @@ void Bullet::_process(float a_Delta) { m_Stuck = true; Vector3 intersectPoint = result["position"]; - auto* head = get_node("Armature"); head->set_global_position(intersectPoint); } +void Bullet::SetTransparency(Node* a_Root, float a_Transparency) { + for (int i = 0; i < a_Root->get_child_count(); i++) { + SetTransparency(a_Root->get_child(i), a_Transparency); + } + + GeometryInstance3D* mesh = Object::cast_to(a_Root); + if (mesh) { + mesh->set_transparency(a_Transparency); + } +} + } // namespace blitz \ No newline at end of file