feat: set up ground ray for blackboard

This commit is contained in:
Sara Gerretsen 2026-05-13 22:04:48 +02:00
parent 2ed026c75f
commit fc8bff058d
3 changed files with 8 additions and 3 deletions

View file

@ -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<PlayerBody>(get_parent());
if (this->player_body) {
this->ground_ray = cast_to<RayCast3D>(this->player_body->get_node(NodePath("GroundRay")));
}
if (this->character) {
this->anim = cast_to<AnimationTree>(this->character->get_node(NodePath("AnimationTree")));
this->hang_ray = cast_to<RayCast3D>(this->character->get_node(NodePath("HangRay")));

View file

@ -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);

View file

@ -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)