Godot 4.5.1
This commit is contained in:
@@ -7,44 +7,44 @@ var interactableArea:InteractableArea
|
||||
var shapeChild:CollisionShape3D
|
||||
|
||||
func _enter_tree() -> void:
|
||||
interactableArea = $InteractableArea
|
||||
interactableArea = $InteractableArea
|
||||
|
||||
if !mapResource:
|
||||
push_error("MapChangeInteract must have a mapResource set.")
|
||||
return
|
||||
if !mapResource:
|
||||
push_error("MapChangeInteract must have a mapResource set.")
|
||||
return
|
||||
|
||||
# Needs to be exactly one child.
|
||||
if get_child_count() != 2:
|
||||
push_error("MapChangeInteract must have exactly one child InteractableArea node.")
|
||||
return
|
||||
# Needs to be exactly one child.
|
||||
if get_child_count() != 2:
|
||||
push_error("MapChangeInteract must have exactly one child InteractableArea node.")
|
||||
return
|
||||
|
||||
var child = get_child(1)
|
||||
if not (child is CollisionShape3D):
|
||||
push_error("MapChangeInteract's child must be an CollisionShape3D node.")
|
||||
var child = get_child(1)
|
||||
if not (child is CollisionShape3D):
|
||||
push_error("MapChangeInteract's child must be an CollisionShape3D node.")
|
||||
|
||||
shapeChild = child
|
||||
remove_child(shapeChild)
|
||||
interactableArea.add_child(shapeChild)
|
||||
shapeChild = child
|
||||
remove_child(shapeChild)
|
||||
interactableArea.add_child(shapeChild)
|
||||
|
||||
interactableArea.interactEvent.connect(onInteract)
|
||||
interactableArea.interactable.connect(onInteractable)
|
||||
interactableArea.notInteractable.connect(onNotInteractable)
|
||||
interactableArea.interactEvent.connect(onInteract)
|
||||
interactableArea.interactable.connect(onInteractable)
|
||||
interactableArea.notInteractable.connect(onNotInteractable)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
interactableArea.interactEvent.disconnect(onInteract)
|
||||
interactableArea.interactable.disconnect(onInteractable)
|
||||
interactableArea.notInteractable.disconnect(onNotInteractable)
|
||||
interactableArea.interactEvent.disconnect(onInteract)
|
||||
interactableArea.interactable.disconnect(onInteractable)
|
||||
interactableArea.notInteractable.disconnect(onNotInteractable)
|
||||
|
||||
interactableArea.remove_child(shapeChild)
|
||||
add_child(shapeChild)
|
||||
interactableArea.remove_child(shapeChild)
|
||||
add_child(shapeChild)
|
||||
|
||||
func onInteract(_ent:Player) -> void:
|
||||
OVERWORLD.mapChange(mapResource, destinationPointNodeName)
|
||||
OVERWORLD.mapChange(mapResource, destinationPointNodeName)
|
||||
|
||||
func onInteractable(_ent:Player) -> void:
|
||||
print("Able to leave map")
|
||||
pass
|
||||
print("Able to leave map")
|
||||
pass
|
||||
|
||||
func onNotInteractable(_ent:Player) -> void:
|
||||
print("Not able to leave map")
|
||||
pass
|
||||
print("Not able to leave map")
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user