set firstperson model invisible

This commit is contained in:
2024-08-24 16:00:16 +02:00
parent da8232f62b
commit 39b9e6039c
2 changed files with 12 additions and 1 deletions

View File

@@ -3,6 +3,8 @@
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/input.hpp>
#include <godot_cpp/classes/input_map.hpp>
#include <godot_cpp/classes/mesh_instance3d.hpp>
#include <godot_cpp/classes/skeleton3d.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
@@ -98,7 +100,14 @@ void Player::BlendAnimation(const godot::String& a_AnimationName, float a_Goal,
a_AnimationName, UtilityFunctions::lerp(m_AnimationTree->get(a_AnimationName), a_Goal, a_Delta * AnimationBlend));
}
void Player::SetModelVisible(bool visible) {}
void Player::SetModelVisible(bool a_Visible) {
auto* skeleton = m_Mesh->get_node<Skeleton3D>("Skeleton3D");
for (int i = 0; i < skeleton->get_child_count(); i++) {
auto* bodyPart = Object::cast_to<MeshInstance3D>(skeleton->get_child(i));
bodyPart->set_cast_shadows_setting(a_Visible ? GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_ON
: GeometryInstance3D::ShadowCastingSetting::SHADOW_CASTING_SETTING_SHADOWS_ONLY);
}
}
Vector3 Player::GetCameraRotation() const {
return m_Player->get_rotation();