TwitchPlaysReverseJenga/scripts/PlayerHand.gd

86 lines
1.6 KiB
GDScript3
Raw Normal View History

extends Node3D
#class_name
#Authored by Tom. Please consult for any modifications or major feature requests.
#region Variables
#Signals
#Enums
#Constants
#Exported Variables
#@export_group("Group")
#@export_subgroup("Subgroup")
2024-05-18 17:10:05 +10:00
@export_group("Config")
@export var moveScale : float = 1
@export_group("Prefabs")
@export var block_scene : PackedScene
@export_group("Node References")
@export var blocks_node : Node3D
2024-05-18 21:43:09 +10:00
@export var gizmo_node : Node3D
#Onready Variables
#Other Variables (please try to separate and organise!)
2024-05-18 17:10:05 +10:00
var current_block : RigidBody3D
#endregion
#region Godot methods
func _ready():
#Runs when all children have entered the tree
pass
#endregion
2024-05-18 21:16:56 +10:00
#region Signal methods
func _on_twitch_link_move_block(direction, amount):
var dir : Vector3
match direction:
"up": dir = Vector3.UP
"down" : dir = Vector3.DOWN
"north" : dir = Vector3.FORWARD
"east" : dir = Vector3.RIGHT
"south" : dir = Vector3.BACK
"west" : dir = Vector3.LEFT
2024-05-18 17:10:05 +10:00
position += dir * amount * moveScale
2024-05-18 18:14:05 +10:00
func _on_twitch_link_rotate_block(direction, amount):
var dir : Vector3
match direction:
2024-05-18 21:43:09 +10:00
"x": dir = Vector3.RIGHT
"y" : dir = Vector3.UP
"z" : dir = Vector3.BACK
2024-05-18 18:14:05 +10:00
rotation_degrees += dir * amount
2024-05-18 21:43:09 +10:00
gizmo_node.rotation_degrees = rotation_degrees
2024-05-18 18:14:05 +10:00
2024-05-18 17:10:05 +10:00
func _on_twitch_link_drop_block():
current_block.freeze = false
current_block.reparent(blocks_node)
func _on_twitch_link_start_turn():
2024-05-18 21:16:56 +10:00
position = Vector3(0,2.28,0)
rotation_degrees = Vector3(0,0,0)
2024-05-18 17:10:05 +10:00
current_block = block_scene.instantiate()
current_block.freeze = true
add_child(current_block)
#endregion
#region Other methods (please try to separate and organise!)
#endregion
2024-05-18 18:14:05 +10:00