added simple interaction script to NPC added a basic ingame UI added ui into World tagged player as playermaster
parent
6e87ca3b09
commit
e2ba115c8f
@ -0,0 +1,41 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="InGameUI" type="CanvasLayer"]
|
||||
|
||||
pause_mode = 2
|
||||
layer = 1
|
||||
offset = Vector2( 0, 0 )
|
||||
rotation = 0.0
|
||||
scale = Vector2( 1, 1 )
|
||||
transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
|
||||
[node name="Container" type="Container" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
|
||||
[node name="DialogWindow" type="PopupDialog" parent="Container" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -180.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
popup_exclusive = true
|
||||
_sections_unfolded = [ "Popup" ]
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
extends Node2D
|
||||
|
||||
# "onready" is a keyword that makes sure that the variable assignment
|
||||
# happens *after* _ready() runs.
|
||||
# the $"" notation is a shorthand for getting a node.
|
||||
# a longer way would be to write get_node("/root")
|
||||
onready var DialogWindow = $"/root".find_node("InGameUI", true, false)
|
||||
|
||||
# start off not ready for interaction, gotta wait until the player is near us
|
||||
var interact_ready = false
|
||||
|
||||
|
||||
func _process(delta):
|
||||
|
||||
# if we're ready for interaction then we should check every frame if "interact" has been pressed
|
||||
if interact_ready and Input.is_action_just_pressed("interact"):
|
||||
print("INTERACTION")
|
||||
|
||||
|
||||
# this function gets called when a physics body enters into the interact_area node's area
|
||||
# if you look in the scene inspector (in the NPC_static scene) you'll see that the interact_area
|
||||
# node has a little wifi signal icon. that means that it has a signal coming out of it attached
|
||||
# to another node. click on it to look at the signal's panel
|
||||
func _on_body_entered(body):
|
||||
|
||||
# in godot you can set a node to be in a group (in the signal panel)
|
||||
# this checks to see if the body entering the area is in the "player" group
|
||||
if body.is_in_group("player"):
|
||||
|
||||
# if the player is this close to us, then we should be ready to interact
|
||||
interact_ready = true
|
||||
|
||||
|
||||
# as you may have guessed, this function runs when a physics body exits the interact area
|
||||
func _on_body_exited(body):
|
||||
|
||||
if body.is_in_group("player"):
|
||||
|
||||
# the player is leaving our vicinity, so we're not ready for interacting
|
||||
interact_ready = false
|
Loading…
Reference in new issue