generated from Persson-dev/Godot-Xmake
set firstperson model invisible
This commit is contained in:
@@ -58,6 +58,8 @@ void FirstPersonPlayer::_ready() {
|
||||
m_Head->add_child(m_Camera);
|
||||
m_Camera->make_current();
|
||||
|
||||
SetModelVisible(false);
|
||||
|
||||
SetPosition({0, 100, 0});
|
||||
SetVelocity({0, 0, 0});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user