Added interactable
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
extends Node
|
||||
class_name Interactable
|
||||
|
||||
signal on_hit
|
||||
|
||||
func hit()->void:
|
||||
on_hit.emit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://d1pa8ssvmxbn
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://be7u1kn41g2ww"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1pa8ssvmxbn" path="res://addons/interaction/interactable.gd" id="1_8h68r"]
|
||||
|
||||
[node name="Interactable" type="Area3D"]
|
||||
script = ExtResource("1_8h68r")
|
||||
@@ -0,0 +1,17 @@
|
||||
extends Node3D
|
||||
@onready var ray_cast: RayCast3D = $RayCast3D
|
||||
|
||||
const Interactable = preload("uid://d1pa8ssvmxbn")
|
||||
|
||||
@export var max_distance: float = 100
|
||||
|
||||
func _ready() -> void:
|
||||
ray_cast.target_position = Vector3(0,0,-max_distance)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("interact"):
|
||||
if ray_cast.is_colliding():
|
||||
var collider = ray_cast.get_collider()
|
||||
if collider.get_script() == Interactable:
|
||||
var interactable: Interactable = collider
|
||||
interactable.hit()
|
||||
@@ -0,0 +1 @@
|
||||
uid://cqf6w5rp1hjcs
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dlryddjharg35"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqf6w5rp1hjcs" path="res://addons/interaction/interaction_ray.gd" id="1_jlrgf"]
|
||||
|
||||
[node name="InteractionRay" type="Node3D"]
|
||||
script = ExtResource("1_jlrgf")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(0, 0, -1)
|
||||
collide_with_areas = true
|
||||
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bxuveo0hlwy33"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cc1m2a1obsyn4" path="res://addons/fpc/character.tscn" id="1_cs6s8"]
|
||||
[ext_resource type="PackedScene" uid="uid://dlryddjharg35" path="res://addons/interaction/interaction_ray.tscn" id="2_xofgc"]
|
||||
|
||||
[node name="Character" instance=ExtResource("1_cs6s8")]
|
||||
|
||||
[node name="InteractionRay" parent="Head" index="3" instance=ExtResource("2_xofgc")]
|
||||
transform = Transform3D(1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0)
|
||||
@@ -18,6 +18,10 @@ config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
|
||||
project/assembly_name="Undertaker Simulator"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PackedStringArray()
|
||||
|
||||
[input]
|
||||
|
||||
left={
|
||||
@@ -55,6 +59,11 @@ sprint={
|
||||
"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":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
interact={
|
||||
"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":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://gq33ysuit61b"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://gq33ysuit61b"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cc1m2a1obsyn4" path="res://addons/fpc/character.tscn" id="1_grf6e"]
|
||||
[ext_resource type="PackedScene" uid="uid://c70o7nk6wxcmx" path="res://models/UndertakerBlockout.fbx" id="2_gfayn"]
|
||||
[ext_resource type="PackedScene" uid="uid://be7u1kn41g2ww" path="res://addons/interaction/interactable.tscn" id="3_u0nvw"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxuveo0hlwy33" path="res://prefabs/character.tscn" id="4_tedjo"]
|
||||
[ext_resource type="Script" uid="uid://b1pyctfbd0wvg" path="res://scenes/debug_printer.gd" id="4_ui586"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gfayn"]
|
||||
size = Vector3(12.2438965, 0.48779297, 13.901489)
|
||||
|
||||
[node name="BlockoutRoom" type="Node3D"]
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_ui586"]
|
||||
size = Vector3(0.24987793, 1, 1)
|
||||
|
||||
[node name="Character" parent="." instance=ExtResource("1_grf6e")]
|
||||
transform = Transform3D(1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 1.96156, 0.12873119, -1.2073363)
|
||||
base_speed = 2.0
|
||||
acceleration = 5.0
|
||||
[node name="BlockoutRoom" type="Node3D"]
|
||||
|
||||
[node name="UndertakerBlockout" parent="." instance=ExtResource("2_gfayn")]
|
||||
|
||||
@@ -26,3 +26,16 @@ transform = Transform3D(0.7260458, 0.59701693, -0.34121642, 0.64276195, -0.41287
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1646729, -0.25610352, 1.5601196)
|
||||
shape = SubResource("BoxShape3D_gfayn")
|
||||
|
||||
[node name="Interactable" parent="." instance=ExtResource("3_u0nvw")]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Interactable"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.1487448, 1.3621653, -0.7917821)
|
||||
shape = SubResource("BoxShape3D_ui586")
|
||||
|
||||
[node name="DebugPrinter" type="Node" parent="."]
|
||||
script = ExtResource("4_ui586")
|
||||
|
||||
[node name="Character" parent="." instance=ExtResource("4_tedjo")]
|
||||
|
||||
[connection signal="on_hit" from="Interactable" to="DebugPrinter" method="_on_interactable_on_hit"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
extends Node
|
||||
|
||||
|
||||
func _on_interactable_on_hit() -> void:
|
||||
print("I was hit")
|
||||
@@ -0,0 +1 @@
|
||||
uid://b1pyctfbd0wvg
|
||||
Reference in New Issue
Block a user