generated from Persson-dev/Godot-Xmake
Random spawn of zombies
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "Zombie.h"
|
||||
|
||||
#include <godot_cpp/classes/engine.hpp>
|
||||
#include <godot_cpp/classes/scene_tree.hpp>
|
||||
#include <godot_cpp/classes/window.hpp>
|
||||
#include <godot_cpp/core/math.hpp>
|
||||
|
||||
using namespace godot;
|
||||
@@ -32,8 +34,13 @@ void Zombie::_ready() {
|
||||
}
|
||||
#endif
|
||||
|
||||
m_Player = Object::cast_to<FirstPersonPlayer>(get_parent()->get_parent()->find_child("FirstPersonPlayer"));
|
||||
DEV_ASSERT(m_Player);
|
||||
godot::Node* scene_root = Object::cast_to<godot::Node>(get_tree()->get_root()->get_child(0));
|
||||
if (scene_root) {
|
||||
m_Player = Object::cast_to<FirstPersonPlayer>(scene_root->find_child("FirstPersonPlayer", true));
|
||||
DEV_ASSERT(m_Player);
|
||||
} else {
|
||||
ERR_PRINT("Scene root not found or invalid.");
|
||||
}
|
||||
m_NavigationAgent = Object::cast_to<NavigationAgent3D>(find_child("NavigationAgent3D"));
|
||||
DEV_ASSERT(m_NavigationAgent);
|
||||
m_AnimationTree = Object::cast_to<AnimationTree>(find_child("AnimationTree"));
|
||||
|
||||
Reference in New Issue
Block a user