started adding interaction system
This commit is contained in:
@@ -55,16 +55,16 @@ mouse_capture={
|
|||||||
"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(142, 6),"global_position":Vector2(146, 47),"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(142, 6),"global_position":Vector2(146, 47),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
flashlight={
|
|
||||||
"deadzone": 0.5,
|
|
||||||
"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":70,"key_label":0,"unicode":102,"echo":false,"script":null)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
jump={
|
jump={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"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":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
"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":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
interact={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"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":69,"key_label":0,"unicode":101,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
86
scenes/interactables/button_stand.tscn
Normal file
86
scenes/interactables/button_stand.tscn
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
[gd_scene load_steps=11 format=3 uid="uid://dqy8bqf1chm8c"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dm8l36ephydnl" path="res://scenes/interaction_area.tscn" id="1_0okd0"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/interactables/button_stand.gd" id="1_uieqm"]
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_jpuiw"]
|
||||||
|
height = 1.4
|
||||||
|
radius = 0.3
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_q60ht"]
|
||||||
|
albedo_color = Color(0.54902, 0.54902, 0.54902, 1)
|
||||||
|
|
||||||
|
[sub_resource type="CylinderMesh" id="CylinderMesh_hgcvq"]
|
||||||
|
material = SubResource("StandardMaterial3D_q60ht")
|
||||||
|
top_radius = 0.3
|
||||||
|
bottom_radius = 0.3
|
||||||
|
height = 1.4
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_crdtx"]
|
||||||
|
albedo_color = Color(0.686275, 0, 0.168627, 1)
|
||||||
|
|
||||||
|
[sub_resource type="CylinderMesh" id="CylinderMesh_g1gjr"]
|
||||||
|
material = SubResource("StandardMaterial3D_crdtx")
|
||||||
|
top_radius = 0.2
|
||||||
|
bottom_radius = 0.2
|
||||||
|
height = 0.1
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_stg1c"]
|
||||||
|
resource_name = "press"
|
||||||
|
length = 0.2
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Button:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 0.750413, 0), Vector3(0, 0.67, 0), Vector3(0, 0.75, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_y5bt0"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Button:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 0.750413, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_um1vs"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_y5bt0"),
|
||||||
|
"press": SubResource("Animation_stg1c")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ButtonStand" type="StaticBody3D"]
|
||||||
|
script = ExtResource("1_uieqm")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("CylinderShape3D_jpuiw")
|
||||||
|
|
||||||
|
[node name="Stand" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("CylinderMesh_hgcvq")
|
||||||
|
|
||||||
|
[node name="Button" type="MeshInstance3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.750413, 0)
|
||||||
|
mesh = SubResource("CylinderMesh_g1gjr")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_um1vs")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="InteractionArea" parent="." instance=ExtResource("1_0okd0")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)
|
||||||
|
|
||||||
|
[connection signal="interacted" from="InteractionArea" to="." method="_on_interaction_area_interacted"]
|
44
scenes/interaction_area.tscn
Normal file
44
scenes/interaction_area.tscn
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dm8l36ephydnl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/interaction_area.gd" id="1_shkh8"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_xlssi"]
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_bc53a"]
|
||||||
|
font_size = 18
|
||||||
|
outline_size = 5
|
||||||
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="InteractionArea" type="Area3D"]
|
||||||
|
script = ExtResource("1_shkh8")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 1, 0)
|
||||||
|
shape = SubResource("BoxShape3D_xlssi")
|
||||||
|
|
||||||
|
[node name="InteractionLabel" type="CanvasLayer" parent="."]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="InteractionLabel"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="InteractionLabel/Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 7.0
|
||||||
|
offset_top = -30.0
|
||||||
|
offset_right = 127.0
|
||||||
|
offset_bottom = -7.0
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "[E] Interagieren"
|
||||||
|
label_settings = SubResource("LabelSettings_bc53a")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="body_exited" from="." to="." method="_on_body_exited"]
|
@@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://ckad8stc13n83"]
|
[gd_scene load_steps=5 format=3 uid="uid://ckad8stc13n83"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://gg5ph541e4p3" path="res://scenes/player.tscn" id="1_2585i"]
|
[ext_resource type="PackedScene" uid="uid://gg5ph541e4p3" path="res://scenes/player.tscn" id="1_2585i"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ddwkhfly2xyyt" path="res://models/interior.obj" id="1_lphcl"]
|
[ext_resource type="PackedScene" uid="uid://ddwkhfly2xyyt" path="res://models/interior.obj" id="1_lphcl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b8bvidqu7tmfs" path="res://scenes/interactables/task_terminal.tscn" id="3_30m3x"]
|
[ext_resource type="PackedScene" uid="uid://b8bvidqu7tmfs" path="res://scenes/interactables/task_terminal.tscn" id="3_30m3x"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dqy8bqf1chm8c" path="res://scenes/interactables/button_stand.tscn" id="4_cruoa"]
|
||||||
|
|
||||||
[node name="Debug" type="Node3D"]
|
[node name="Debug" type="Node3D"]
|
||||||
|
|
||||||
@@ -21,3 +22,6 @@ transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -
|
|||||||
[node name="DirectionalLight3D2" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D2" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.866016, 0.29244, -0.40558, 0.5, 0.5, -0.707107, -0.00399622, -0.815156, -0.579228, 0, 0, 0)
|
transform = Transform3D(-0.866016, 0.29244, -0.40558, 0.5, 0.5, -0.707107, -0.00399622, -0.815156, -0.579228, 0, 0, 0)
|
||||||
light_energy = 0.5
|
light_energy = 0.5
|
||||||
|
|
||||||
|
[node name="ButtonStand" parent="." instance=ExtResource("4_cruoa")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.7, 0)
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://eok3g18b83f0"]
|
|
||||||
|
|
||||||
[ext_resource type="MeshLibrary" uid="uid://c2bhu7trxj2ef" path="res://assets/meshlib/housing.tres" id="2_68k16"]
|
|
||||||
|
|
||||||
[node name="Level1" type="Node3D"]
|
|
||||||
|
|
||||||
[node name="GridMap" type="GridMap" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.01438, 0)
|
|
||||||
mesh_library = ExtResource("2_68k16")
|
|
||||||
metadata/_editor_floor_ = Vector3(0, -1, 0)
|
|
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
|
extends CharacterBody3D
|
||||||
|
class_name Player
|
||||||
|
|
||||||
|
|
||||||
const SPEED = 5.0
|
const SPEED = 5.0
|
||||||
|
Reference in New Issue
Block a user