From 172eb8acbd4c8ff5d48a920ed604feb7b66e2f9b Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Tue, 11 Oct 2022 14:58:23 -0400 Subject: [PATCH 1/2] Animation vraiment basic de la main --- HUD.tscn | 24 +++++++-------- Player.gd | 10 ++++-- Player.tscn | 84 ++++++++++++++++++++++++++++++++++++++++++++++++--- project.godot | 5 +++ 4 files changed, 103 insertions(+), 20 deletions(-) diff --git a/HUD.tscn b/HUD.tscn index 64a0b8d..4037a6f 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -105,30 +105,28 @@ theme = SubResource( 8 ) text = "New Game" [node name="ActualHUD" type="Control" parent="."] +anchor_left = 0.037 +anchor_top = 0.914 +anchor_right = 0.037 +anchor_bottom = 0.916 margin_right = 40.0 margin_bottom = 40.0 theme = SubResource( 10 ) [node name="SlapGauge" type="ColorRect" parent="ActualHUD"] material = SubResource( 11 ) -anchor_left = 12.875 -anchor_top = 7.625 -anchor_right = 12.875 -anchor_bottom = 7.625 -margin_left = -451.0 -margin_top = 218.0 -margin_right = -161.0 -margin_bottom = 241.0 +margin_right = 291.36 +margin_bottom = 23.0 script = ExtResource( 1 ) -[node name="SlapLabel" type="Label" parent="ActualHUD"] +[node name="SlapLabel" type="Label" parent="ActualHUD/SlapGauge"] modulate = Color( 1, 1, 1, 0.611765 ) anchor_left = 12.662 anchor_top = 7.324 anchor_right = 12.662 anchor_bottom = 7.324 -margin_left = -436.48 -margin_top = 229.04 -margin_right = -325.48 -margin_bottom = 261.04 +margin_left = -3683.2 +margin_top = -169.452 +margin_right = -3572.2 +margin_bottom = -137.452 text = "Slap" diff --git a/Player.gd b/Player.gd index e711e88..f8606e2 100644 --- a/Player.gd +++ b/Player.gd @@ -23,10 +23,12 @@ var gravity_vec = Vector3() onready var head = $Head onready var ground_check = $GroundCheck -onready var SlapGauge = $HUD/ActualHUD/SlapGauge +onready var slap_gauge = $HUD/ActualHUD/SlapGauge +onready var slap_animator = $HandMovement func _ready(): Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + slap_animator.current_animation = "basic_slap" func _input(event): if event is InputEventMouseMotion: @@ -82,8 +84,9 @@ func _physics_process(delta): else: slap -= delta * 8.0; slap = clamp(slap, 0.0, 1.0) - SlapGauge.fill = slap; + slap_gauge.fill = slap + slap_animator.seek(slap, true) direction = direction.normalized() h_velocity = h_velocity.linear_interpolate(direction * speed, h_acceleration * delta) @@ -91,4 +94,7 @@ func _physics_process(delta): movement.x = h_velocity.x + gravity_vec.x movement.y = gravity_vec.y + + +# warning-ignore:return_value_discarded move_and_slide(movement, Vector3.UP) diff --git a/Player.tscn b/Player.tscn index e717002..be1cca9 100644 --- a/Player.tscn +++ b/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 format=2] [ext_resource path="res://Player.gd" type="Script" id=1] [ext_resource path="res://BlenderStuff/Hand/protohand.obj" type="ArrayMesh" id=2] @@ -14,6 +14,72 @@ height = 3.0 albedo_texture = ExtResource( 3 ) uv1_triplanar = true +[sub_resource type="Animation" id=5] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("Head/HandParent/Hand:transform") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Transform( -0.178665, 0.385633, 0.0293721, 0.386578, 0.177103, 0.0262457, 0.0115471, 0.0376593, -0.4242, 1.33036, -0.0718137, -2.73514 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Head/HandParent/Hand:translation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector3( 0.329, 1.317, 0 ) ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("Head/HandParent/Hand:rotation_degrees") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector3( -20.757, 0, 0 ) ] +} + +[sub_resource type="Animation" id=6] +resource_name = "basic_slap" +tracks/0/type = "value" +tracks/0/path = NodePath("Head/HandParent/Hand:translation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector3( 0, 0, 0 ), Vector3( -0.103, 2.756, 0 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("Head/HandParent/Hand:rotation_degrees") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector3( 0, 0, 0 ), Vector3( -36.146, -1.281, 0 ) ] +} + [node name="Player" type="KinematicBody"] script = ExtResource( 1 ) @@ -29,13 +95,17 @@ shape = SubResource( 3 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.84218, 0 ) [node name="Camera" type="Camera" parent="Head"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.343071, -0.253136 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0154071, 0.355, -0.246618 ) +fov = 80.0 -[node name="Hand" type="MeshInstance" parent="Head"] -transform = Transform( -0.178665, 0.385633, 0.029372, 0.386578, 0.177104, 0.0262457, 0.0115471, 0.0376592, -0.4242, 1.33036, -0.0718137, -2.73514 ) +[node name="HandParent" type="Spatial" parent="Head"] +transform = Transform( 0.0807126, 0.49343, -0.00351894, 0.445393, -0.0713166, 0.215728, 0.212391, -0.0379586, -0.451053, 0.736, -0.075, -1.998 ) + +[node name="Hand" type="MeshInstance" parent="Head/HandParent"] +transform = Transform( 0.426025, 0, 0, 0, 0.398372, 0.150985, 0, -0.150985, 0.398372, 0.329, 1.317, 0 ) cast_shadow = 0 mesh = ExtResource( 2 ) -skeleton = NodePath("../..") +skeleton = NodePath("../../..") material/0 = SubResource( 4 ) [node name="GroundCheck" type="RayCast" parent="."] @@ -44,3 +114,7 @@ enabled = true cast_to = Vector3( 0, -1.5, 0 ) [node name="HUD" parent="." instance=ExtResource( 4 )] + +[node name="HandMovement" type="AnimationPlayer" parent="."] +anims/RESET = SubResource( 5 ) +anims/basic_slap = SubResource( 6 ) diff --git a/project.godot b/project.godot index 15b8f86..62954b6 100644 --- a/project.godot +++ b/project.godot @@ -16,6 +16,11 @@ config/icon="res://icon.png" [display] +window/size/width=1920 +window/size/height=1080 +window/size/test_width=1280 +window/size/test_height=720 +window/stretch/mode="viewport" window/stretch/aspect="keep" [gui] From 104f0c5f9268a51429d0ccb7bdccb9c6554bc886 Mon Sep 17 00:00:00 2001 From: Victor Turgeon Date: Tue, 11 Oct 2022 15:07:07 -0400 Subject: [PATCH 2/2] no depth test for the hand --- HUD.tscn | 7 +------ Player.gd | 12 ++++-------- Player.tscn | 4 +++- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/HUD.tscn b/HUD.tscn index 77086c7..4667c2a 100644 --- a/HUD.tscn +++ b/HUD.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://SlapGauge.gd" type="Script" id=1] [ext_resource path="res://Start.gd" type="Script" id=2] @@ -51,11 +51,6 @@ shader_param/kill = null shader_param/bkgcol = Plane( 0, 0, 0, 0.3 ) shader_param/kilcol = Plane( 0.5, 0, 0, 0.3 ) -[sub_resource type="DynamicFont" id=12] -size = 33 -use_filter = true -font_data = ExtResource( 3 ) - [sub_resource type="DynamicFont" id=7] size = 88 outline_size = 5 diff --git a/Player.gd b/Player.gd index db631cc..f396c08 100644 --- a/Player.gd +++ b/Player.gd @@ -26,17 +26,13 @@ onready var head = $Head onready var ground_check = $GroundCheck onready var slap_gauge = $HUD/ActualHUD/SlapGauge onready var slap_animator = $HandMovement - -func _ready(): - Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - slap_animator.current_animation = "basic_slap" -onready var SlapGauge = $HUD/ActualHUD/SlapGauge onready var Menu = $HUD/Start onready var AudioSlap = $AudioSlap onready var AudioMegaSlap = $AudioMegaSlap func _ready(): - pass + slap_animator.current_animation = "basic_slap" + func _input(event): if event is InputEventMouseMotion: @@ -106,8 +102,8 @@ func _physics_process(delta): slap_gauge.fill = slap slap_animator.seek(slap, true) - SlapGauge.fill = slap; - SlapGauge.kill = slapkill; + slap_gauge.fill = slap; + slap_gauge.kill = slapkill; direction = direction.normalized() diff --git a/Player.tscn b/Player.tscn index fd6387c..4da6f3f 100644 --- a/Player.tscn +++ b/Player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://Player.gd" type="Script" id=1] [ext_resource path="res://BlenderStuff/Hand/protohand.obj" type="ArrayMesh" id=2] @@ -13,6 +13,7 @@ height = 3.0 [sub_resource type="CylinderShape" id=3] [sub_resource type="SpatialMaterial" id=4] +flags_no_depth_test = true albedo_texture = ExtResource( 3 ) uv1_triplanar = true @@ -120,6 +121,7 @@ cast_to = Vector3( 0, -1.5, 0 ) [node name="HandMovement" type="AnimationPlayer" parent="."] anims/RESET = SubResource( 5 ) anims/basic_slap = SubResource( 6 ) + [node name="AudioSlap" type="AudioStreamPlayer3D" parent="."] stream = ExtResource( 5 )