Skip to content

Commit

Permalink
Merge pull request #118 from FailSpy/carry-auto-drop
Browse files Browse the repository at this point in the history
Add automatic leave() for deleted carried objects
  • Loading branch information
Phazorknight authored Mar 13, 2024
2 parents bde8798 + 80c01fb commit ae169c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions COGITO/Components/Interactions/CarryableComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func _on_body_entered(body):
if body.is_in_group("Player") and is_being_carried:
leave()

func _exit_tree():
if is_being_carried:
leave()

func hold():
if lock_rotation_when_carried:
Expand All @@ -74,8 +77,9 @@ func hold():
func leave():
if lock_rotation_when_carried:
parent_object.set_lock_rotation_enabled(false)
player_interaction_component.stop_carrying()
player_interaction_component.interaction_raycast.remove_exception(parent_object)
if player_interaction_component and is_instance_valid(player_interaction_component):
player_interaction_component.stop_carrying()
player_interaction_component.interaction_raycast.remove_exception(parent_object)
is_being_carried = false


Expand Down

0 comments on commit ae169c6

Please sign in to comment.