started adding interaction system
This commit is contained in:
6
scripts/interactables/button_stand.gd
Normal file
6
scripts/interactables/button_stand.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
func _on_interaction_area_interacted():
|
||||
animation_player.play("press")
|
19
scripts/interaction_area.gd
Normal file
19
scripts/interaction_area.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Area3D
|
||||
|
||||
signal interacted
|
||||
|
||||
var player_entered: bool
|
||||
@onready var interaction_label: CanvasLayer = $InteractionLabel
|
||||
func _on_body_entered(body):
|
||||
if body is Player:
|
||||
player_entered = true
|
||||
interaction_label.show()
|
||||
|
||||
func _on_body_exited(body):
|
||||
if body is Player:
|
||||
player_entered = false
|
||||
interaction_label.hide()
|
||||
|
||||
func _input(event):
|
||||
if player_entered && event.is_action_pressed("interact"):
|
||||
interacted.emit()
|
@@ -1,4 +1,5 @@
|
||||
extends CharacterBody3D
|
||||
class_name Player
|
||||
|
||||
|
||||
const SPEED = 5.0
|
||||
|
Reference in New Issue
Block a user