rotation gizmo partial

This commit is contained in:
Clevertop 2024-05-18 21:16:56 +10:00
parent bcb17faaed
commit ff0d1a5156
8 changed files with 184 additions and 6 deletions

View file

@ -1,11 +1,16 @@
[gd_scene load_steps=21 format=3 uid="uid://bdtfounpnyaoo"]
[gd_scene load_steps=26 format=3 uid="uid://bdtfounpnyaoo"]
[ext_resource type="Script" path="res://twitch/jengacommands.gd" id="1_so2ke"]
[ext_resource type="Script" path="res://scripts/JengaManager.gd" id="1_xtpjd"]
[ext_resource type="Shader" path="res://addons/water_shader/shaders/water.gdshader" id="2_rliwp"]
[ext_resource type="Material" uid="uid://bwrsgjub33pd4" path="res://materials/BaseMaterial.tres" id="2_txp0l"]
[ext_resource type="Script" path="res://scripts/PivotMover.gd" id="3_7e1m6"]
[ext_resource type="Script" path="res://scripts/PlayerHand.gd" id="4_kq4yo"]
[ext_resource type="PackedScene" uid="uid://b2fnlbcm3p6f" path="res://prefabs/block.tscn" id="5_mn8hr"]
[ext_resource type="Material" uid="uid://dd5vcwp8smlnt" path="res://materials/Green.tres" id="8_2httq"]
[ext_resource type="Material" uid="uid://doxtu8jdlr3tp" path="res://materials/Red.tres" id="9_swpv7"]
[ext_resource type="Material" uid="uid://bipwt04wjyv6v" path="res://materials/Blue.tres" id="10_5k7a5"]
[ext_resource type="Material" uid="uid://cndp0uelk5w8u" path="res://materials/Blue2.tres" id="10_faljs"]
[sub_resource type="Environment" id="Environment_h6sx5"]
ambient_light_color = Color(1, 1, 1, 1)
@ -99,6 +104,7 @@ scopes = Array[String](["chat:edit", "chat:read", "moderator:read:followers"])
[node name="CameraPivot" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.445, 0)
script = ExtResource("3_7e1m6")
[node name="Camera3D" type="Camera3D" parent="CameraPivot"]
transform = Transform3D(1, 0, 0, 0, 0.819152, 0.573576, 0, -0.573576, 0.819152, 0, 0, 4.12)
@ -165,7 +171,95 @@ offset_bottom = 23.0
text = "meow"
label_settings = SubResource("LabelSettings_y2xp5")
[node name="SubViewportContainer" type="SubViewportContainer" parent="UserInterface"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -128.0
offset_bottom = 128.0
grow_horizontal = 0
stretch = true
[node name="SubViewport" type="SubViewport" parent="UserInterface/SubViewportContainer"]
size = Vector2i(128, 128)
size_2d_override = Vector2i(225, 190)
[node name="Camera3D" type="Camera3D" parent="UserInterface/SubViewportContainer/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 0.819152, 0.573576, 0, -0.573576, 0.819152, 0, 52.925, 4.12)
cull_mask = 524288
fov = 28.2
[node name="TransformGizmo" type="Node3D" parent="UserInterface/SubViewportContainer/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0)
[node name="YAxis" type="CSGTorus3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
layers = 524288
material_override = ExtResource("8_2httq")
inner_radius = 0.84
sides = 20
ring_sides = 10
[node name="XAxis" type="CSGTorus3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0)
layers = 524288
material_override = ExtResource("9_swpv7")
inner_radius = 0.84
sides = 20
ring_sides = 10
[node name="ZAxis" type="CSGTorus3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 0, 0)
layers = 524288
material_override = ExtResource("10_faljs")
inner_radius = 0.84
sides = 20
ring_sides = 10
[node name="Arrow" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(1, 0, 0, 0, 0.740617, 0.671927, 0, -0.671927, 0.740617, 0, 0.528221, 0.857041)
layers = 524288
material_override = ExtResource("9_swpv7")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[node name="Arrow5" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(-4.37114e-08, 0.707107, -0.707107, 0, -0.707107, -0.707107, -1, -3.09086e-08, 3.09086e-08, 0.367916, 0.75111, 2.09664e-08)
layers = 524288
material_override = ExtResource("10_5k7a5")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[node name="Arrow6" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(-1.81058e-08, -0.707107, -0.707107, 6.18172e-08, 0.707107, -0.707107, 1, -5.65141e-08, 3.09086e-08, -0.577203, -0.807655, 1.00213e-07)
layers = 524288
material_override = ExtResource("10_5k7a5")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[node name="Arrow2" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(-1, -8.74228e-08, 0, 6.47468e-08, -0.740617, 0.671928, -5.87418e-08, 0.671927, 0.740617, 2.86072e-08, -0.438335, -0.695322)
layers = 524288
material_override = ExtResource("9_swpv7")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[node name="Arrow3" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(0.63384, -0.773464, -8.74228e-08, 2.16029e-08, -9.53244e-08, 1, -0.773464, -0.63384, -4.37114e-08, -0.454012, 0.102974, 0.816248)
layers = 524288
material_override = ExtResource("8_2httq")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[node name="Arrow4" type="CSGPolygon3D" parent="UserInterface/SubViewportContainer/SubViewport/TransformGizmo"]
transform = Transform3D(-0.63384, 0.773464, -8.74228e-08, -2.16029e-08, 9.53244e-08, 1, 0.773464, 0.63384, -4.37114e-08, 0.450658, 0.102974, -0.783165)
layers = 524288
material_override = ExtResource("8_2httq")
polygon = PackedVector2Array(0, 0, 0.2, 0.4, -0.2, 0.4)
depth = 0.2
[connection signal="dropBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_drop_block"]
[connection signal="moveBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_move_block"]
[connection signal="rotateBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_rotate_block"]
[connection signal="rotateCamera" from="TwitchLink" to="CameraPivot" method="_on_twitch_link_rotate_camera"]
[connection signal="startTurn" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_start_turn"]

4
materials/Blue.tres Normal file
View file

@ -0,0 +1,4 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://bipwt04wjyv6v"]
[resource]
albedo_color = Color(0, 0.792157, 0.172549, 1)

4
materials/Blue2.tres Normal file
View file

@ -0,0 +1,4 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://cndp0uelk5w8u"]
[resource]
albedo_color = Color(0, 0.713726, 0.956863, 1)

3
materials/Green.tres Normal file
View file

@ -0,0 +1,3 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://dd5vcwp8smlnt"]
[resource]

4
materials/Red.tres Normal file
View file

@ -0,0 +1,4 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://doxtu8jdlr3tp"]
[resource]
albedo_color = Color(1, 0.215686, 0.258824, 1)

57
scripts/PivotMover.gd Normal file
View file

@ -0,0 +1,57 @@
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")
@export var rotation_speed : float = 20 #degrees per second
@export var height_speed : float = 0.5 # m per second
#Onready Variables
#Other Variables (please try to separate and organise!)
var target_rotation : float = 0
var target_height : float = 3.445
#endregion
#region Godot methods
func _ready():
#Runs when all children have entered the tree
pass
func _process(delta):
if abs(rotation_degrees.y - target_rotation) < 1:
rotation_degrees.y = target_rotation
else:
if(target_rotation > rotation_degrees.y):
rotation_degrees.y += rotation_speed * delta
else:
rotation_degrees.y -= rotation_speed * delta
pass
#endregion
#region Signal methods
func _on_twitch_link_rotate_camera(direction, amount):
var dir
match direction:
"left" : dir = -1
"right" : dir = 1
target_rotation += dir * float(amount)
#endregion
#region Other methods (please try to separate and organise!)
#endregion

View file

@ -31,11 +31,10 @@ func _ready():
#Runs when all children have entered the tree
pass
func _process(delta):
#Runs per frame
pass
#endregion
#region Signal methods
func _on_twitch_link_move_block(direction, amount):
var dir : Vector3
@ -66,7 +65,8 @@ func _on_twitch_link_drop_block():
func _on_twitch_link_start_turn():
position = Vector3(0,3,0)
position = Vector3(0,2.28,0)
rotation_degrees = Vector3(0,0,0)
current_block = block_scene.instantiate()
current_block.freeze = true
add_child(current_block)

View file

@ -2,6 +2,7 @@ extends Gift
signal moveBlock(direction : String, amount : float)
signal rotateBlock(direction : String, amount : float)
signal rotateCamera(direction : String, amount : float)
signal dropBlock()
signal startTurn()
@ -66,6 +67,8 @@ func _ready() -> void:
add_command("leave_queue", leave_queue)
add_command("start_turn", start_turn)
add_command("pass_turn", pass_turn)
add_aliases("join_queue", ["jq", "join"])
add_aliases("start_turn", ["st", "start"])
## Gameplay Commands
#camera movement command - !camera left 20 (moves camera left 20 units)
@ -149,7 +152,8 @@ func start_turn(cmd_info : CommandInfo):
func pass_turn(cmd_info : CommandInfo):
#allow the player to pass their turn and leave the queue if they no longer wish to play
jenga_manager.turn_timer = 0 #might change this later depeding on how i set up penalties
if(cmd_info.sender_data.tags["display-name"] == jenga_manager.current_player and jenga_manager.turn_started):
jenga_manager.turn_timer = 0 #might change this later depeding on how i set up penalties
pass
@ -157,6 +161,14 @@ func pass_turn(cmd_info : CommandInfo):
func camera(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
chat("moving camera " + arg_ary[0] + " by " + arg_ary[1] + " degrees")
if(cmd_info.sender_data.tags["display-name"] == jenga_manager.current_player and jenga_manager.turn_started) :
var chosenDirection = arg_ary[0].to_lower()
var validDirections = ["left","right"]
if(validDirections.has(chosenDirection)):
rotateCamera.emit(arg_ary[0],float(arg_ary[1]))
chat("moving camera " + arg_ary[0] + " by " + arg_ary[1] + " degrees")
else:
chat("invalid direction :(")
func move(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
if(cmd_info.sender_data.tags["display-name"] == jenga_manager.current_player and jenga_manager.turn_started) :