feat: PlayerBehaviourTree references animationtree
This commit is contained in:
parent
4d61f123eb
commit
058fc459a9
2 changed files with 8 additions and 2 deletions
|
|
@ -7,9 +7,10 @@
|
|||
#include "scene/main/viewport.h"
|
||||
|
||||
void PlayerBehaviourTree::_bind_methods() {
|
||||
BIND_PROPERTY(Variant::VECTOR2, move_input);
|
||||
BIND_HPROPERTY(Variant::VECTOR2, move_input, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_READ_ONLY);
|
||||
BIND_HPROPERTY(Variant::OBJECT, player_body, PROPERTY_HINT_NODE_TYPE, "PlayerBody", PROPERTY_USAGE_NO_EDITOR);
|
||||
BIND_HPROPERTY(Variant::OBJECT, character, PROPERTY_HINT_NODE_TYPE, "Node3D");
|
||||
BIND_HPROPERTY(Variant::OBJECT, anim, PROPERTY_HINT_NODE_TYPE, "AnimationPlayer", PROPERTY_USAGE_READ_ONLY);
|
||||
ClassDB::bind_method(D_METHOD("get_world_move_input"), &self_type::get_world_move_input);
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +23,9 @@ void PlayerBehaviourTree::_notification(int what) {
|
|||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
this->player_body = cast_to<PlayerBody>(get_parent());
|
||||
this->character = cast_to<Node3D>(this->player_body->get_node(NodePath("Character")));
|
||||
if (this->character) {
|
||||
this->anim = cast_to<AnimationTree>(this->character->get_node(NodePath("AnimationTree")));
|
||||
}
|
||||
return;
|
||||
case NOTIFICATION_READY:
|
||||
set_process_unhandled_input(true);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "core/object/class_db.h"
|
||||
#include "macros.h"
|
||||
#include "player_body.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
|
||||
class PlayerBehaviourTree : public BehaviourTree {
|
||||
GDCLASS(PlayerBehaviourTree, BehaviourTree);
|
||||
|
|
@ -20,9 +21,11 @@ private:
|
|||
Vector2 move_input{ 0, 0 };
|
||||
PlayerBody *player_body{ nullptr };
|
||||
Node3D *character{ nullptr };
|
||||
AnimationTree *anim{ nullptr };
|
||||
|
||||
public:
|
||||
GET_SET_FNS(Vector2, move_input);
|
||||
GET_SET_FNS(PlayerBody *, player_body);
|
||||
GET_SET_FNS(Node3D *, character);
|
||||
GET_SET_FNS(AnimationTree *, anim);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue