Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make interactions be blocked by Environment safely #114

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions COGITO/Components/PlayerInteractionComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -266,13 +269,14 @@ 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
FailSpy marked this conversation as resolved.
Show resolved Hide resolved
var camera = get_viewport().get_camera_3d()

var Ray_Origin = camera.project_ray_origin(viewport/2)
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():
Expand Down
2 changes: 1 addition & 1 deletion COGITO/PrefabScenes/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
1 change: 1 addition & 0 deletions COGITO/Scripts/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.exclude_player(get_rid())

randomize()

Expand Down