19 lines
344 B
GDScript3
19 lines
344 B
GDScript3
|
|
extends CharacterBody2D
|
||
|
|
|
||
|
|
var playerInArea = false
|
||
|
|
|
||
|
|
func _input(event):
|
||
|
|
if playerInArea && Input.is_action_pressed('select'):
|
||
|
|
talk()
|
||
|
|
|
||
|
|
func talk():
|
||
|
|
print('Hi friend!')
|
||
|
|
|
||
|
|
func _on_area_2d_body_entered(body):
|
||
|
|
if body.name == 'player':
|
||
|
|
playerInArea = true
|
||
|
|
|
||
|
|
func _on_area_2d_body_exited(body):
|
||
|
|
if body.name == 'player':
|
||
|
|
playerInArea = false
|