added user action
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=16 format=3 uid="uid://0t0cvsitlfmm"]
|
[gd_scene load_steps=18 format=3 uid="uid://0t0cvsitlfmm"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_nn5da"]
|
[ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_nn5da"]
|
||||||
[ext_resource type="ArrayMesh" uid="uid://cahq2fdeqqwhx" path="res://Blends/Mobel/DoubleBeds.obj" id="2_8ssp7"]
|
[ext_resource type="ArrayMesh" uid="uid://cahq2fdeqqwhx" path="res://Blends/Mobel/DoubleBeds.obj" id="2_8ssp7"]
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://lbbig7lpdun3" path="res://Blends/Mobel/textures/Material.003 Roughness.png" id="4_dn7et"]
|
[ext_resource type="Texture2D" uid="uid://lbbig7lpdun3" path="res://Blends/Mobel/textures/Material.003 Roughness.png" id="4_dn7et"]
|
||||||
[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="5_c1046"]
|
[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="5_c1046"]
|
||||||
[ext_resource type="Texture2D" uid="uid://kl1jplui8wfq" path="res://Blends/Mobel/textures/Material.003 Base Color.png" id="5_sp2kd"]
|
[ext_resource type="Texture2D" uid="uid://kl1jplui8wfq" path="res://Blends/Mobel/textures/Material.003 Base Color.png" id="5_sp2kd"]
|
||||||
|
[ext_resource type="Script" uid="uid://fjdtka5s1dxi" path="res://Scripts/objects/DoubleBeds.gd" id="8_c1046"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_dn7et"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_dn7et"]
|
||||||
render_priority = 0
|
render_priority = 0
|
||||||
@@ -44,6 +45,9 @@ albedo_texture = ExtResource("5_sp2kd")
|
|||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_sp2kd"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_sp2kd"]
|
||||||
size = Vector3(5.62061, 2.52063, 2.12427)
|
size = Vector3(5.62061, 2.52063, 2.12427)
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_c1046"]
|
||||||
|
radius = 0.870929
|
||||||
|
|
||||||
[node name="DoubleBeds" type="Node3D" node_paths=PackedStringArray("meshInstance")]
|
[node name="DoubleBeds" type="Node3D" node_paths=PackedStringArray("meshInstance")]
|
||||||
script = ExtResource("1_nn5da")
|
script = ExtResource("1_nn5da")
|
||||||
meshInstance = NodePath("DoubleBeds")
|
meshInstance = NodePath("DoubleBeds")
|
||||||
@@ -61,3 +65,17 @@ surface_material_override/2 = SubResource("StandardMaterial3D_tma46")
|
|||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.218994, -0.287048, 0.10144)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.218994, -0.287048, 0.10144)
|
||||||
shape = SubResource("BoxShape3D_sp2kd")
|
shape = SubResource("BoxShape3D_sp2kd")
|
||||||
|
|
||||||
|
[node name="ActionNode" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.3739)
|
||||||
|
script = ExtResource("8_c1046")
|
||||||
|
|
||||||
|
[node name="Area3d" type="Area3D" parent="ActionNode"]
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="ActionNode/Area3d"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.839141, 0.470829)
|
||||||
|
shape = SubResource("SphereShape3D_c1046")
|
||||||
|
|
||||||
|
[node name="CSGSphere3D" type="CSGSphere3D" parent="ActionNode/Area3d"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.839141, 0.470829)
|
||||||
|
radius = 0.886475
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ avoidance_enabled = true
|
|||||||
debug_enabled = true
|
debug_enabled = true
|
||||||
|
|
||||||
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_navigation_finished"]
|
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_navigation_finished"]
|
||||||
|
[connection signal="target_reached" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_target_reached"]
|
||||||
|
|||||||
10
Scripts/Interactable.gd
Normal file
10
Scripts/Interactable.gd
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class_name Interactable
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var can_pick: bool
|
||||||
|
|
||||||
|
var can_store: bool
|
||||||
|
var stored_objects: Array
|
||||||
|
|
||||||
|
func action(person):
|
||||||
|
print("action!")
|
||||||
1
Scripts/Interactable.gd.uid
Normal file
1
Scripts/Interactable.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dt4rrjht2fx2b
|
||||||
@@ -14,6 +14,7 @@ signal preview_created
|
|||||||
signal preview_destroyed
|
signal preview_destroyed
|
||||||
|
|
||||||
signal object_placed(build_postion)
|
signal object_placed(build_postion)
|
||||||
|
signal object_added(object)
|
||||||
|
|
||||||
var build_mode: bool = false
|
var build_mode: bool = false
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ var is_object_selected: bool
|
|||||||
|
|
||||||
var global_y = 2.903
|
var global_y = 2.903
|
||||||
|
|
||||||
|
var builded_objects: Array
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
is_object_selected = false
|
is_object_selected = false
|
||||||
@@ -52,3 +54,8 @@ func get_preview_object():
|
|||||||
|
|
||||||
func _on_object_selected():
|
func _on_object_selected():
|
||||||
is_object_selected = true
|
is_object_selected = true
|
||||||
|
|
||||||
|
|
||||||
|
func add_object_to_array(object):
|
||||||
|
builded_objects.append(object)
|
||||||
|
object_added.emit(object)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extends Node3D
|
|||||||
|
|
||||||
var default_shaders: Array
|
var default_shaders: Array
|
||||||
var staic_body: StaticBody3D
|
var staic_body: StaticBody3D
|
||||||
|
var ActionNode: Node3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
BuildManager.preview_created.connect(_on_preview_create)
|
BuildManager.preview_created.connect(_on_preview_create)
|
||||||
@@ -17,8 +17,8 @@ func _ready() -> void:
|
|||||||
staic_body = $StaticBody3D
|
staic_body = $StaticBody3D
|
||||||
staic_body.mouse_entered.connect(_on_mouse_enter)
|
staic_body.mouse_entered.connect(_on_mouse_enter)
|
||||||
staic_body.mouse_exited.connect(_on_mouse_exit)
|
staic_body.mouse_exited.connect(_on_mouse_exit)
|
||||||
print(staic_body)
|
|
||||||
|
|
||||||
|
ActionNode = $ActionNode
|
||||||
|
|
||||||
func set_default_shaders():
|
func set_default_shaders():
|
||||||
var amount_shaders = meshInstance.get_surface_override_material_count()
|
var amount_shaders = meshInstance.get_surface_override_material_count()
|
||||||
@@ -53,7 +53,8 @@ func _on_preview_create():
|
|||||||
|
|
||||||
|
|
||||||
func _on_object_placed(build_postion):
|
func _on_object_placed(build_postion):
|
||||||
|
#BuildManager.add_object_to_array(self)
|
||||||
|
#print(ActionNode.global_position)
|
||||||
restore_default_shaders()
|
restore_default_shaders()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,5 @@ func _input(event: InputEvent) -> void:
|
|||||||
func _on_object_placed(build_postion):
|
func _on_object_placed(build_postion):
|
||||||
var newObject = BuildManager.get_preview_object().instantiate()
|
var newObject = BuildManager.get_preview_object().instantiate()
|
||||||
newObject.global_position = build_postion
|
newObject.global_position = build_postion
|
||||||
|
BuildManager.add_object_to_array(newObject)
|
||||||
self.add_child(newObject)
|
self.add_child(newObject)
|
||||||
|
|||||||
@@ -4,25 +4,12 @@ extends Node3D
|
|||||||
|
|
||||||
@export var debugLabel1: Label
|
@export var debugLabel1: Label
|
||||||
|
|
||||||
#signal exit_build_mode
|
signal interact(person,interact_object)
|
||||||
#signal enter_build_mode
|
|
||||||
#
|
|
||||||
#signal preview_created
|
|
||||||
#signal preview_destroyed
|
|
||||||
#
|
|
||||||
#signal object_placed(build_postion)
|
|
||||||
#
|
|
||||||
#var build_mode: bool = false
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
print(outline_shader)
|
print(outline_shader)
|
||||||
|
|
||||||
#func _input(event: InputEvent) -> void:
|
interact.connect(_on_interact)
|
||||||
#if event.is_action_released("enter_build_mode"):
|
|
||||||
#if build_mode:
|
|
||||||
#exit_build_mode.emit()
|
|
||||||
#build_mode = false
|
|
||||||
#else:
|
|
||||||
#enter_build_mode.emit()
|
|
||||||
#build_mode = true
|
|
||||||
|
|
||||||
|
func _on_interact(person, object):
|
||||||
|
object.action(person)
|
||||||
|
|||||||
9
Scripts/objects/DoubleBeds.gd
Normal file
9
Scripts/objects/DoubleBeds.gd
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
extends Interactable
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
can_pick = false
|
||||||
|
can_store = false
|
||||||
|
|
||||||
|
|
||||||
|
func action(person):
|
||||||
|
print(str(person) + " is sleeping")
|
||||||
1
Scripts/objects/DoubleBeds.gd.uid
Normal file
1
Scripts/objects/DoubleBeds.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://fjdtka5s1dxi
|
||||||
@@ -6,18 +6,19 @@ var shirt_shader: ShaderMaterial
|
|||||||
var meshI: MeshInstance3D
|
var meshI: MeshInstance3D
|
||||||
|
|
||||||
var start_pos: Vector3
|
var start_pos: Vector3
|
||||||
|
var target_object: Node3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
nav_agent = $NavigationAgent3D
|
nav_agent = $NavigationAgent3D
|
||||||
meshI = $MeshInstance3D
|
meshI = $MeshInstance3D
|
||||||
shirt_shader = meshI.get_surface_override_material(1)
|
shirt_shader = meshI.get_surface_override_material(1)
|
||||||
|
|
||||||
BuildManager.object_placed.connect(_on_object_placed)
|
BuildManager.object_added.connect(_on_object_added)
|
||||||
|
|
||||||
set_random_shirt()
|
set_random_shirt()
|
||||||
|
|
||||||
start_pos = global_position
|
start_pos = global_position
|
||||||
|
|
||||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
@@ -26,10 +27,12 @@ func _physics_process(delta: float) -> void:
|
|||||||
velocity = new_velocity
|
velocity = new_velocity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("test"):
|
||||||
|
set_target_position()
|
||||||
|
|
||||||
|
func _on_object_added(object):
|
||||||
func _on_object_placed(build_position):
|
set_target(object)
|
||||||
nav_agent.target_position = Vector3(-14.305,3.486,-59.836)
|
|
||||||
|
|
||||||
|
|
||||||
func set_random_shirt():
|
func set_random_shirt():
|
||||||
@@ -38,5 +41,19 @@ func set_random_shirt():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
func _on_navigation_agent_3d_navigation_finished() -> void:
|
func set_target(object):
|
||||||
nav_agent.target_position = start_pos
|
target_object = object
|
||||||
|
#nav_agent.target_position = target_object.ActionNode.global_position
|
||||||
|
func set_target_position():
|
||||||
|
var newPos = target_object.ActionNode.global_position
|
||||||
|
newPos.y = self.position.y
|
||||||
|
nav_agent.target_position = newPos
|
||||||
|
|
||||||
|
|
||||||
|
#nav_agent.target_position = start_pos
|
||||||
|
|
||||||
|
|
||||||
|
func _on_navigation_agent_3d_target_reached() -> void:
|
||||||
|
if target_object != null:
|
||||||
|
Global.interact.emit(self, target_object.ActionNode)
|
||||||
|
pass
|
||||||
|
|||||||
@@ -52,3 +52,8 @@ mouse_click={
|
|||||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(146, 26),"global_position":Vector2(155, 74),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(146, 26),"global_position":Vector2(155, 74),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
test={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user