pedestals working
This commit is contained in:
parent
813feb9fef
commit
4a564dc3f5
6 changed files with 109 additions and 9 deletions
14
Assets/Materials/green_floor.tres
Normal file
14
Assets/Materials/green_floor.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://didvwdmm46bmq"]
|
||||||
|
|
||||||
|
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_78k07"]
|
||||||
|
load_path = "res://.godot/imported/stone_2_gray_0.png-9d16a4858afb7acd70485069983b75ce.s3tc.ctex"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
albedo_color = Color(0.325915, 1, 0.29823, 1)
|
||||||
|
albedo_texture = SubResource("CompressedTexture2D_78k07")
|
||||||
|
emission = Color(1, 1, 1, 1)
|
||||||
|
subsurf_scatter_strength = 1.0
|
||||||
|
uv1_scale = Vector3(3, 2, 1)
|
||||||
|
uv1_triplanar_sharpness = 0.0583145
|
||||||
|
uv2_triplanar_sharpness = 0.170755
|
||||||
|
texture_filter = 0
|
||||||
16
Commands/command_pedestal.gd
Normal file
16
Commands/command_pedestal.gd
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends Node3D
|
||||||
|
class_name Pedestal
|
||||||
|
|
||||||
|
@export var placed_command : Node3D
|
||||||
|
@export var has_command : bool = false
|
||||||
|
@export var slot : Node3D
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
||||||
25
Commands/command_pedestal.tscn
Normal file
25
Commands/command_pedestal.tscn
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://cq4rfdsc5kghr"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Commands/command_pedestal.gd" id="1_02nqv"]
|
||||||
|
[ext_resource type="Material" uid="uid://cr4ra7ijk1uec" path="res://Assets/Materials/floor.tres" id="2_rgb2l"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_hrk6g"]
|
||||||
|
material = ExtResource("2_rgb2l")
|
||||||
|
size = Vector3(0.8, 1, 0.8)
|
||||||
|
|
||||||
|
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_8evcs"]
|
||||||
|
data = PackedVector3Array(-0.4, 0.5, 0.4, 0.4, 0.5, 0.4, -0.4, -0.5, 0.4, 0.4, 0.5, 0.4, 0.4, -0.5, 0.4, -0.4, -0.5, 0.4, 0.4, 0.5, -0.4, -0.4, 0.5, -0.4, 0.4, -0.5, -0.4, -0.4, 0.5, -0.4, -0.4, -0.5, -0.4, 0.4, -0.5, -0.4, 0.4, 0.5, 0.4, 0.4, 0.5, -0.4, 0.4, -0.5, 0.4, 0.4, 0.5, -0.4, 0.4, -0.5, -0.4, 0.4, -0.5, 0.4, -0.4, 0.5, -0.4, -0.4, 0.5, 0.4, -0.4, -0.5, -0.4, -0.4, 0.5, 0.4, -0.4, -0.5, 0.4, -0.4, -0.5, -0.4, 0.4, 0.5, 0.4, -0.4, 0.5, 0.4, 0.4, 0.5, -0.4, -0.4, 0.5, 0.4, -0.4, 0.5, -0.4, 0.4, 0.5, -0.4, -0.4, -0.5, 0.4, 0.4, -0.5, 0.4, -0.4, -0.5, -0.4, 0.4, -0.5, 0.4, 0.4, -0.5, -0.4, -0.4, -0.5, -0.4)
|
||||||
|
|
||||||
|
[node name="CommandPedestal" type="StaticBody3D" node_paths=PackedStringArray("slot")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||||
|
script = ExtResource("1_02nqv")
|
||||||
|
slot = NodePath("slot")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("BoxMesh_hrk6g")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("ConcavePolygonShape3D_8evcs")
|
||||||
|
|
||||||
|
[node name="slot" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.567907, 0)
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -6,15 +6,14 @@ signal broadcast(command : String)
|
||||||
@export_group("Variables")
|
@export_group("Variables")
|
||||||
@export var level_tick : float = 1 # how often to run a command
|
@export var level_tick : float = 1 # how often to run a command
|
||||||
@export var level_time : float = 10 # the amoutn of time allowed for the level
|
@export var level_time : float = 10 # the amoutn of time allowed for the level
|
||||||
@export var commands : Array[String]
|
|
||||||
|
|
||||||
@export_group("Node References")
|
@export_group("Node References")
|
||||||
@export var gui : Control
|
@export var gui : Control
|
||||||
|
@export var pedestals : Array[Pedestal]
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
while(commands.size() < level_time / level_tick): # prevent index out of bounds error
|
|
||||||
commands.append("")
|
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -22,8 +21,7 @@ func _ready():
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func set_command(position : int, command : String):
|
|
||||||
commands[position] = command
|
|
||||||
|
|
||||||
func start_room():
|
func start_room():
|
||||||
# open door
|
# open door
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ func _physics_process(delta):
|
||||||
if Input.is_action_just_pressed("interact"):
|
if Input.is_action_just_pressed("interact"):
|
||||||
if "name" in raycast.get_collider():
|
if "name" in raycast.get_collider():
|
||||||
if "command_name" in raycast.get_collider():
|
if "command_name" in raycast.get_collider():
|
||||||
|
# clicked a command block
|
||||||
print(raycast.get_collider().command_name)
|
print(raycast.get_collider().command_name)
|
||||||
|
|
||||||
#hand.add_child(held_object)
|
#hand.add_child(held_object)
|
||||||
|
|
@ -52,6 +53,18 @@ func _physics_process(delta):
|
||||||
held_object.position = Vector3(0,0,0)
|
held_object.position = Vector3(0,0,0)
|
||||||
held_object.freeze = true
|
held_object.freeze = true
|
||||||
has_object = true
|
has_object = true
|
||||||
|
elif "placed_command" in raycast.get_collider():
|
||||||
|
# clicked a pedestal, place on pedestal if its not already got something
|
||||||
|
var clicked_pedestal = raycast.get_collider() as Pedestal
|
||||||
|
print("clicked pedestal: "+ clicked_pedestal.name)
|
||||||
|
if(has_object and not clicked_pedestal.has_command):
|
||||||
|
print("trying to place")
|
||||||
|
held_object.reparent(clicked_pedestal.slot)
|
||||||
|
held_object.position = Vector3(0,0,0)
|
||||||
|
held_object.rotation_degrees = Vector3(0,0,0)
|
||||||
|
has_object = false
|
||||||
|
clicked_pedestal.has_command = true
|
||||||
|
clicked_pedestal.placed_command = held_object
|
||||||
else:
|
else:
|
||||||
print(raycast.get_collider().name)
|
print(raycast.get_collider().name)
|
||||||
object_clicked.emit(raycast.get_collider())
|
object_clicked.emit(raycast.get_collider())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue