Added Interact system with a raycast

This commit is contained in:
2024-06-03 23:39:36 -05:00
parent 1003bc186e
commit 9f76eacaad
5 changed files with 122 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://61lt10ktv534"]
[ext_resource type="PackedScene" uid="uid://bihywi2gve5j0" path="res://Assets/Models/LightPost.fbx" id="1_ksctp"]
[ext_resource type="PackedScene" uid="uid://d3doutiwh4shy" path="res://Blender Files/LightPost.blend" id="1_n4j6v"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_o8c43"]
height = 5.65653
@ -8,8 +8,12 @@ radius = 0.473027
[node name="Lamp Post" type="StaticBody3D"]
[node name="Root Scene" parent="." instance=ExtResource("1_ksctp")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00153413, 2.85853, -0.00286096)
shape = SubResource("CylinderShape3D_o8c43")
[node name="LightPost" parent="." instance=ExtResource("1_n4j6v")]
[node name="OmniLight3D" type="OmniLight3D" parent="LightPost"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.66802, 0)
omni_range = 8.60491

View File

@ -1,8 +1,11 @@
[gd_scene load_steps=5 format=3 uid="uid://bcjijcf8br8t4"]
[gd_scene load_steps=8 format=3 uid="uid://bcjijcf8br8t4"]
[ext_resource type="Script" path="res://Assets/scripts/player.gd" id="1_b2ij4"]
[ext_resource type="Script" path="res://Assets/scripts/Head.gd" id="2_is0vo"]
[ext_resource type="Script" path="res://Assets/scripts/vapelight.gd" id="2_ndvgb"]
[ext_resource type="Script" path="res://Assets/scripts/InteractRay.gd" id="4_x7epo"]
[ext_resource type="Texture2D" uid="uid://c786idyo8hs4l" path="res://Assets/textures/Crosshair.png" id="5_4upch"]
[ext_resource type="Theme" uid="uid://dx4a66pg3q8cy" path="res://Assets/Resources/UI_Theme.tres" id="5_qcry7"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lm3xc"]
@ -30,6 +33,40 @@ spot_angle = 62.91
spot_angle_attenuation = 1.38495
script = ExtResource("2_ndvgb")
[node name="RayCast3D" type="RayCast3D" parent="Head"]
target_position = Vector3(0, 0, -4)
script = ExtResource("4_x7epo")
[node name="Prompt" type="Label" parent="Head/RayCast3D"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -39.0
offset_top = 14.0
offset_right = 40.0
offset_bottom = 30.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("5_qcry7")
text = "Press E"
[node name="Crosshair" type="TextureRect" parent="Head"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -10.0
offset_top = -10.0
offset_right = 10.0
offset_bottom = 10.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("5_4upch")
stretch_mode = 2
[node name="Severe Coughing Timer" type="Timer" parent="."]
wait_time = 10.0

View File

@ -0,0 +1,17 @@
extends RayCast3D
@onready var prompt = $"Prompt"
# Called when the node enters the scene tree for the first time.
func _ready():
add_exception(owner)
func _physics_process(delta):
prompt.text = ""
if is_colliding():
var collider = get_collider()
if collider is Interactable:
prompt.text = "Press E"
if Input.is_action_just_pressed("interact"):
collider.interact(owner)

10
Assets/scripts/vape.gd Normal file
View File

@ -0,0 +1,10 @@
class_name Interactable
extends Node3D
@export var promt_message:String
@export var promt_key:String
func interact(player):
print("vape picked up")
get_parent().get_parent().queue_free()

View File

@ -0,0 +1,50 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://d3doutiwh4shy"
path="res://.godot/imported/LightPost.blend-df549e2c96d3c6dfc0e2299cca8d83a5.scn"
[deps]
source_file="res://Blender Files/LightPost.blend"
dest_files=["res://.godot/imported/LightPost.blend-df549e2c96d3c6dfc0e2299cca8d83a5.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true