diff --git a/modules/viscosity/player_behaviour_tree.cpp b/modules/viscosity/player_behaviour_tree.cpp index 700fb51c..ec20a3ee 100644 --- a/modules/viscosity/player_behaviour_tree.cpp +++ b/modules/viscosity/player_behaviour_tree.cpp @@ -12,6 +12,7 @@ void PlayerBehaviourTree::_bind_methods() { BIND_HPROPERTY(Variant::OBJECT, character, PROPERTY_HINT_NODE_TYPE, "Node3D"); BIND_HPROPERTY(Variant::OBJECT, anim, PROPERTY_HINT_NODE_TYPE, "AnimationPlayer", PROPERTY_USAGE_READ_ONLY); BIND_HPROPERTY(Variant::OBJECT, hang_ray, PROPERTY_HINT_NODE_TYPE, "RayCast3D", PROPERTY_USAGE_READ_ONLY); + BIND_HPROPERTY(Variant::OBJECT, ground_ray, PROPERTY_HINT_NODE_TYPE, "RayCast3D", PROPERTY_USAGE_READ_ONLY); ClassDB::bind_method(D_METHOD("get_world_move_input"), &self_type::get_world_move_input); } @@ -24,6 +25,9 @@ void PlayerBehaviourTree::_notification(int what) { return; case NOTIFICATION_ENTER_TREE: this->player_body = cast_to(get_parent()); + if (this->player_body) { + this->ground_ray = cast_to(this->player_body->get_node(NodePath("GroundRay"))); + } if (this->character) { this->anim = cast_to(this->character->get_node(NodePath("AnimationTree"))); this->hang_ray = cast_to(this->character->get_node(NodePath("HangRay"))); diff --git a/modules/viscosity/player_behaviour_tree.h b/modules/viscosity/player_behaviour_tree.h index 899c37ab..ffccbb3a 100644 --- a/modules/viscosity/player_behaviour_tree.h +++ b/modules/viscosity/player_behaviour_tree.h @@ -25,8 +25,10 @@ private: Node3D *character{ nullptr }; AnimationTree *anim{ nullptr }; RayCast3D *hang_ray{ nullptr }; + RayCast3D *ground_ray{ nullptr }; public: + GET_SET_FNS(RayCast3D *, ground_ray); GET_SET_FNS(Vector2, move_input); GET_SET_FNS(PlayerBody *, player_body); GET_SET_FNS(Node3D *, character); diff --git a/project/objects/player.tscn b/project/objects/player.tscn index ad094d76..c2b0bf38 100644 --- a/project/objects/player.tscn +++ b/project/objects/player.tscn @@ -369,10 +369,9 @@ floor_snap_length = 0.3 [node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1143027860] shape = SubResource("CapsuleShape3D_bxedw") -[node name="HeightRay" type="RayCast3D" parent="." unique_id=1763928231] -unique_name_in_owner = true +[node name="GroundRay" type="RayCast3D" parent="." unique_id=1763928231] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0) -target_position = Vector3(0, -100, 0) +target_position = Vector3(0, -500, 0) [node name="PlayerModel" parent="." unique_id=1710695753 instance=ExtResource("1_eqqp1")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)