From b697995037255a06f372f8ae89bda282af30103c Mon Sep 17 00:00:00 2001 From: FailSpy <9100196+FailSpy@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:15:07 -0400 Subject: [PATCH 1/3] Old layer config; raycast exclude player colliders --- COGITO/PrefabScenes/player.tscn | 2 +- COGITO/Scripts/player.gd | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/COGITO/PrefabScenes/player.tscn b/COGITO/PrefabScenes/player.tscn index 40d96f5d..efd44a9d 100644 --- a/COGITO/PrefabScenes/player.tscn +++ b/COGITO/PrefabScenes/player.tscn @@ -98,7 +98,7 @@ libraries = { [node name="InteractionRaycast" type="RayCast3D" parent="Neck/Head/Eyes/Camera"] target_position = Vector3(0, 0, -2.5) -collision_mask = 2 +collision_mask = 3 [node name="Wieldables" type="Node3D" parent="Neck/Head"] diff --git a/COGITO/Scripts/player.gd b/COGITO/Scripts/player.gd index c14ff567..a9fed689 100644 --- a/COGITO/Scripts/player.gd +++ b/COGITO/Scripts/player.gd @@ -138,6 +138,7 @@ func _ready(): #Some Setup steps CogitoSceneManager._current_player_node = self player_interaction_component.interaction_raycast = $Neck/Head/Eyes/Camera/InteractionRaycast + player_interaction_component.interaction_raycast.add_exception_rid(get_rid()) randomize() From 5c775a27c69a75029c309bcee6d0a3b16f1171e5 Mon Sep 17 00:00:00 2001 From: FailSpy <9100196+FailSpy@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:51:17 -0400 Subject: [PATCH 2/3] Exclude player for camera raycasts --- COGITO/Components/PlayerInteractionComponent.gd | 6 +++++- COGITO/Scripts/player.gd | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/COGITO/Components/PlayerInteractionComponent.gd b/COGITO/Components/PlayerInteractionComponent.gd index 49eb65e6..c4ba131b 100644 --- a/COGITO/Components/PlayerInteractionComponent.gd +++ b/COGITO/Components/PlayerInteractionComponent.gd @@ -35,13 +35,16 @@ var is_changing_wieldables : bool = false #Used to avoid any input acitons while var equipped_wieldable_item = null var equipped_wieldable_node = null var is_wielding : bool - +var player_rid func _ready(): #for node in wieldable_nodes: #node.hide() object_detected = false +func exclude_player(rid : RID): + player_rid = rid + interaction_raycast.add_exception_rid(rid) func _process(_delta): # when carrying object, disable all other prompts. @@ -273,6 +276,7 @@ func Get_Camera_Collision() -> Vector3: var Ray_End = Ray_Origin + camera.project_ray_normal(viewport/2)*equipped_wieldable_item.wieldable_range var New_Intersection = PhysicsRayQueryParameters3D.create(Ray_Origin,Ray_End) + New_Intersection.exclude = [player_rid] var Intersection = get_world_3d().direct_space_state.intersect_ray(New_Intersection) if not Intersection.is_empty(): diff --git a/COGITO/Scripts/player.gd b/COGITO/Scripts/player.gd index a9fed689..4f8f9d08 100644 --- a/COGITO/Scripts/player.gd +++ b/COGITO/Scripts/player.gd @@ -138,7 +138,7 @@ func _ready(): #Some Setup steps CogitoSceneManager._current_player_node = self player_interaction_component.interaction_raycast = $Neck/Head/Eyes/Camera/InteractionRaycast - player_interaction_component.interaction_raycast.add_exception_rid(get_rid()) + player_interaction_component.exclude_player(get_rid()) randomize() From e9f9c89ffa10e429c55dff54030dc25bc6441cdd Mon Sep 17 00:00:00 2001 From: FailSpy <9100196+FailSpy@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:29:17 -0400 Subject: [PATCH 3/3] Fix viewport issues with window res that differs from viewport render res --- COGITO/Components/PlayerInteractionComponent.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COGITO/Components/PlayerInteractionComponent.gd b/COGITO/Components/PlayerInteractionComponent.gd index c4ba131b..f0b28c31 100644 --- a/COGITO/Components/PlayerInteractionComponent.gd +++ b/COGITO/Components/PlayerInteractionComponent.gd @@ -269,7 +269,7 @@ func send_hint(hint_icon,hint_text): # This gets a world space collision point of whatever the camera is pointed at, depending on the equipped wieldable range. func Get_Camera_Collision() -> Vector3: - var viewport = get_viewport().get_size() + var viewport = get_viewport().get_visible_rect().size var camera = get_viewport().get_camera_3d() var Ray_Origin = camera.project_ray_origin(viewport/2)