26 lines
522 B
GDScript
26 lines
522 B
GDScript
extends Sprite3D
|
|
|
|
class_name InteractiveObject
|
|
|
|
var player: Player = null
|
|
|
|
func _ready() -> void:
|
|
pass
|
|
|
|
func _process(_delta: float) -> void:
|
|
if player == null:
|
|
return
|
|
if Input.is_action_just_pressed('interact'):
|
|
_interact(player)
|
|
|
|
func _on_body_entered(body: Node3D) -> void:
|
|
if body is Player:
|
|
player = body
|
|
|
|
func _on_body_exited(body: Node3D) -> void:
|
|
if body is Player:
|
|
player = null
|
|
|
|
## Invoked when interact action was used when player is in object's area
|
|
func _interact(_player: Player) -> void:
|
|
pass
|