Added Night stand animation to open and close when interacted with and fixed interaction ray so I don't have to use classes and I can just have it use the intractable physics layer
This commit is contained in:
File diff suppressed because one or more lines are too long
76
Assets/Objects/night_stand.tscn
Normal file
76
Assets/Objects/night_stand.tscn
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
[gd_scene load_steps=8 format=3 uid="uid://cvlwiscksxvr8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Assets/scripts/night_stand.gd" id="1_5m56a"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://r7id1vke7msb" path="res://Blender Files/Objects/NightStand.blend" id="1_50kbp"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_k5x08"]
|
||||||
|
size = Vector3(0.799194, 0.494141, 0.799316)
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_wocdj"]
|
||||||
|
resource_name = "Open"
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("NightStand/Drawer:blend_shapes/Drawer")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 1),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 1.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_4ron5"]
|
||||||
|
resource_name = "Close"
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("NightStand/Drawer:blend_shapes/Drawer")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 1),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [1.0, 0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_yurxo"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("NightStand/Drawer:blend_shapes/Drawer")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_q4jho"]
|
||||||
|
_data = {
|
||||||
|
"Close": SubResource("Animation_4ron5"),
|
||||||
|
"Open": SubResource("Animation_wocdj"),
|
||||||
|
"RESET": SubResource("Animation_yurxo")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Night Stand" type="StaticBody3D"]
|
||||||
|
collision_layer = 4
|
||||||
|
script = ExtResource("1_5m56a")
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000183105, 0.24707, -0.000244141)
|
||||||
|
shape = SubResource("BoxShape3D_k5x08")
|
||||||
|
|
||||||
|
[node name="NightStand" parent="." instance=ExtResource("1_50kbp")]
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_q4jho")
|
||||||
|
}
|
||||||
|
|
||||||
|
[editable path="NightStand"]
|
||||||
@ -10,7 +10,7 @@ func _physics_process(delta):
|
|||||||
prompt.text = ""
|
prompt.text = ""
|
||||||
if is_colliding():
|
if is_colliding():
|
||||||
var collider = get_collider()
|
var collider = get_collider()
|
||||||
if collider is Interactable:
|
if collider:
|
||||||
prompt.text = collider.promt_message
|
prompt.text = collider.promt_message
|
||||||
if Input.is_action_just_pressed("interact"):
|
if Input.is_action_just_pressed("interact"):
|
||||||
collider.interact(owner)
|
collider.interact(owner)
|
||||||
|
|||||||
13
Assets/scripts/night_stand.gd
Normal file
13
Assets/scripts/night_stand.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
extends StaticBody3D
|
||||||
|
|
||||||
|
@export var promt_message:String = "press e"
|
||||||
|
@export var promt_key:String
|
||||||
|
var is_open = false
|
||||||
|
|
||||||
|
func interact(player):
|
||||||
|
if not is_open:
|
||||||
|
$AnimationPlayer.play("Open")
|
||||||
|
is_open = true
|
||||||
|
else:
|
||||||
|
$AnimationPlayer.play("Close")
|
||||||
|
is_open = false
|
||||||
50
Blender Files/Objects/NightStand.blend.import
Normal file
50
Blender Files/Objects/NightStand.blend.import
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://r7id1vke7msb"
|
||||||
|
path="res://.godot/imported/NightStand.blend-5dd61a5157f8ca599f80aa146919ff24.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Blender Files/Objects/NightStand.blend"
|
||||||
|
dest_files=["res://.godot/imported/NightStand.blend-5dd61a5157f8ca599f80aa146919ff24.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
|
||||||
Reference in New Issue
Block a user