Skip to content

Commit

Permalink
Merge pull request #7 from ARPGLTD/DropCarriedObjectWithPrimaryAction
Browse files Browse the repository at this point in the history
Add "Drop" interaction prompt when carrying an object
  • Loading branch information
Phazorknight authored Jan 2, 2024
2 parents 87639ab + 6d35eef commit 693f8dd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions COGITO/Components/PlayerInteractionComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func _ready():
node.hide()

func _process(_delta):
if interaction_raycast.is_colliding():
# when carrying object, disable all other prompts.
if carried_object:
emit_signal("interaction_prompt", "Drop")
elif interaction_raycast.is_colliding():
var interactable = interaction_raycast.get_collider()
is_reset = false
if interactable != null and interactable.has_method("interact"):
Expand All @@ -52,6 +55,11 @@ func _process(_delta):
func _input(event):
if event.is_action_pressed("interact"):

# if carrying an object, drop it.
if carried_object:
carried_object.throw(throw_power)
carried_object = null

if interaction_raycast.is_colliding():
var interactable = interaction_raycast.get_collider()
if interactable.has_method("interact"):
Expand All @@ -63,14 +71,9 @@ func _input(event):
send_hint(null,"Can't carry an object while wielding.")
elif interactable.has_method("carry"):
interactable.carry(self)

else:
if carried_object != null and carried_object.has_method("carry"):
emit_signal("set_use_prompt", "")
carried_object.throw(throw_power)


# Wieldable primary Action Input
if !get_parent().is_movement_paused:
if !get_parent().is_movement_paused:
if is_wielding and Input.is_action_just_pressed("action_primary"):
attempt_action_primary()

Expand Down

0 comments on commit 693f8dd

Please sign in to comment.