setup NPC dialog interractable
This commit is contained in:
parent
4a8ab2317d
commit
f17b1f7402
|
|
@ -66,8 +66,13 @@ func process_physics(delta):
|
|||
physics_delta = delta
|
||||
if has_method('_state_process_physics_' + current_state.name):
|
||||
call('_state_process_physics_' + current_state.name)
|
||||
# else:
|
||||
# move_actor_as_desired()
|
||||
else:
|
||||
apply_movement_to_parent(
|
||||
velocity_controller.calculate_velocity(
|
||||
physics_delta ,
|
||||
apply_state_modifier(current_state.get_movement_parameters()),
|
||||
Vector2(0,1) )
|
||||
)
|
||||
|
||||
# more likely needed for Players
|
||||
func process_physics_input(delta):
|
||||
|
|
|
|||
|
|
@ -54,6 +54,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://lib/templates/Interactable/Interactable.gd"
|
||||
}, {
|
||||
"base": "Interactable",
|
||||
"class": "Interactable_NPC_Dialog",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/Interactables/interactable_npc_dialog.gd"
|
||||
}, {
|
||||
"base": "Node",
|
||||
"class": "Interactable_Receiver",
|
||||
"language": "GDScript",
|
||||
|
|
@ -184,6 +189,7 @@ _global_script_class_icons={
|
|||
"HealthComponent": "",
|
||||
"HealthPickup": "",
|
||||
"Interactable": "",
|
||||
"Interactable_NPC_Dialog": "",
|
||||
"Interactable_Receiver": "",
|
||||
"InventoryManager": "",
|
||||
"Item": "",
|
||||
|
|
|
|||
18
src/Interactables/interactable_npc_dialog.gd
Normal file
18
src/Interactables/interactable_npc_dialog.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class_name Interactable_NPC_Dialog
|
||||
extends Interactable
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
export (String) var dialog_text
|
||||
export (bool) var auto_start = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
#func _ready():
|
||||
# pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
10
src/Interactables/interactable_npc_dialog.tscn
Normal file
10
src/Interactables/interactable_npc_dialog.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://src/Interactables/interactable_npc_dialog.gd" type="Script" id=1]
|
||||
|
||||
[node name="NPC_Dialog" type="Area2D"]
|
||||
collision_layer = 0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_Interactable_Component_body_entered"]
|
||||
[connection signal="body_exited" from="." to="." method="_on_Interactable_Component_body_exited"]
|
||||
|
|
@ -1,12 +1,17 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/actors/npcs/WarriorGirl/WarriorGirl.tres" type="SpriteFrames" id=2]
|
||||
[ext_resource path="res://src/actors/npcs/default.tres" type="Resource" id=3]
|
||||
[ext_resource path="res://src/Interactables/interactable_npc_dialog.tscn" type="PackedScene" id=4]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 9, 14 )
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 6.0
|
||||
height = 58.0
|
||||
|
||||
[node name="WarriorGirl" instance=ExtResource( 1 )]
|
||||
scale = Vector2( -1, 1 )
|
||||
collision_layer = 0
|
||||
|
|
@ -22,3 +27,12 @@ playing = true
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
|
||||
position = Vector2( -5, 6 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="NPC_Dialog" parent="." index="5" instance=ExtResource( 4 )]
|
||||
dialog_text = "Hello, I am a human."
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="NPC_Dialog" index="0"]
|
||||
modulate = Color( 0, 1, 0, 1 )
|
||||
position = Vector2( -5, 6 )
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user