diff --git a/scenes/game.tscn b/scenes/game.tscn index f1746b7..0ed07d2 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -6,6 +6,7 @@ [ext_resource type="Texture2D" uid="uid://b6krbvbco0jt6" path="res://textures/shadow.png" id="4_lbhrr"] [ext_resource type="Texture2D" uid="uid://3ptkafoafq14" path="res://textures/character-leg.png" id="4_u5sy4"] [ext_resource type="PackedScene" uid="uid://b0kty7juk7rfo" path="res://models/stalagmite.gltf" id="5_iywne"] +[ext_resource type="Texture2D" uid="uid://rgxhw23471ut" path="res://textures/character-arm.png" id="5_u5sy4"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_lbhrr"] albedo_color = Color(0.61, 0.28791997, 0.17079999, 1) @@ -88,6 +89,54 @@ tracks/5/keys = { "update": 0, "values": [Vector3(0, 0, 0)] } +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(), +"transitions": PackedFloat32Array(), +"update": 0, +"values": [] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Body/ArmPivot/FrontArm:position") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(), +"transitions": PackedFloat32Array(), +"update": 0, +"values": [] +} +tracks/8/type = "value" +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/keys = { +"times": PackedFloat32Array(), +"transitions": PackedFloat32Array(), +"update": 0, +"values": [] +} +tracks/9/type = "value" +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/path = NodePath("Body/ArmPivot/BackArm:position") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/keys = { +"times": PackedFloat32Array(), +"transitions": PackedFloat32Array(), +"update": 0, +"values": [] +} [sub_resource type="Animation" id="Animation_u5sy4"] resource_name = "fall" @@ -165,6 +214,30 @@ tracks/5/keys = { "update": 0, "values": [Vector3(0, 0, 0)] } +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 1.134464)] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, -1.134464)] +} [sub_resource type="Animation" id="Animation_p57ef"] resource_name = "jump" @@ -241,6 +314,131 @@ tracks/5/keys = { "update": 0, "values": [Vector3(0, 0, 0), Vector3(0, 0, 0.06981317), Vector3(0, 0, 0)] } +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0, 0.06666667, 0.18), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0.08726646), Vector3(0, 0, 0.61086524), Vector3(0, 0, 0.5235988)] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0, 0.06666667, 0.18), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, -0.08726646), Vector3(0, 0, -0.61086524), Vector3(0, 0, -0.5235988)] +} + +[sub_resource type="Animation" id="Animation_vtaks"] +resource_name = "leap" +length = 0.2 +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Body/FrontLeg:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0.045, -0.09000015, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Body/FrontLeg:rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0.10471976)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Body/BackLeg:position") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(-0.044999994, -0.09000015, 0)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Body/BackLeg:rotation") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0.10471976)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Body:position") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0)] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Body:rotation") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0.0033333339), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0)] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0.033333335), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0.5235988)] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0.033333335), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, -0.5235988)] +} [sub_resource type="Animation" id="Animation_0tnpc"] resource_name = "move" @@ -269,15 +467,55 @@ tracks/1/keys = { "update": 0, "values": [Vector3(0, 0, 0.34906584), Vector3(0, 0, -0.34906584), Vector3(0, 0, 0.34906584)] } +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.5, 1), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, -0.17453292), Vector3(0, 0, 0.17453292), Vector3(0, 0, -0.17453292)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.5, 1), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0.17453292), Vector3(0, 0, -0.17453292), Vector3(0, 0, 0.17453292)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Body:position") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(), +"transitions": PackedFloat32Array(), +"update": 0, +"values": [] +} [sub_resource type="AnimationLibrary" id="AnimationLibrary_vtaks"] _data = { &"RESET": SubResource("Animation_gee14"), &"fall": SubResource("Animation_u5sy4"), &"jump": SubResource("Animation_p57ef"), +&"leap": SubResource("Animation_vtaks"), &"move": SubResource("Animation_0tnpc") } +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vtaks"] +animation = &"leap" + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_p57ef"] animation = &"jump" @@ -288,6 +526,8 @@ animation = &"fall" [sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_u5sy4"] +[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_kvpfn"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_gee14"] animation = &"move" @@ -299,10 +539,10 @@ animation = &"RESET" [sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_p57ef"] [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_kvpfn"] -graph_offset = Vector2(-299.60645, 18.418121) -nodes/output/position = Vector2(1020, 160) +graph_offset = Vector2(-228.28757, 27.085762) +nodes/output/position = Vector2(1140, 140) nodes/jump/node = SubResource("AnimationNodeOneShot_u5sy4") -nodes/jump/position = Vector2(680, 140) +nodes/jump/position = Vector2(860, 140) nodes/reset/node = SubResource("AnimationNodeAnimation_0tnpc") nodes/reset/position = Vector2(60, 20) nodes/move/node = SubResource("AnimationNodeAnimation_gee14") @@ -310,14 +550,18 @@ nodes/move/position = Vector2(-80, 220) nodes/walk/node = SubResource("AnimationNodeBlend2_vtaks") nodes/walk/position = Vector2(240, 80) nodes/Animation/node = SubResource("AnimationNodeAnimation_p57ef") -nodes/Animation/position = Vector2(480, 360) +nodes/Animation/position = Vector2(680, 420) nodes/walk_speed/node = SubResource("AnimationNodeTimeScale_p57ef") nodes/walk_speed/position = Vector2(80, 220) nodes/fall/node = SubResource("AnimationNodeBlend2_gee14") nodes/fall/position = Vector2(480, 100) nodes/fall_anim/node = SubResource("AnimationNodeAnimation_u5sy4") nodes/fall_anim/position = Vector2(260, 400) -node_connections = [&"output", 0, &"jump", &"jump", 0, &"fall", &"jump", 1, &"Animation", &"walk", 0, &"reset", &"walk", 1, &"walk_speed", &"walk_speed", 0, &"move", &"fall", 0, &"walk", &"fall", 1, &"fall_anim"] +"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_vtaks") +"nodes/Animation 2/position" = Vector2(480, 420) +nodes/leap/node = SubResource("AnimationNodeBlend2_kvpfn") +nodes/leap/position = Vector2(670.4032, 137.15503) +node_connections = [&"output", 0, &"jump", &"jump", 0, &"leap", &"jump", 1, &"Animation", &"walk", 0, &"reset", &"walk", 1, &"walk_speed", &"walk_speed", 0, &"move", &"fall", 0, &"walk", &"fall", 1, &"fall_anim", &"leap", 0, &"fall", &"leap", 1, &"Animation 2"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_yqjtg"] radius = 0.25 @@ -364,6 +608,25 @@ pixel_size = 0.03 texture_filter = 0 texture = ExtResource("4_u5sy4") +[node name="ArmPivot" type="Node3D" parent="Player/DreamerBody/Body" unique_id=101320487] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1500001, 0) + +[node name="FrontArm" type="Sprite3D" parent="Player/DreamerBody/Body/ArmPivot" unique_id=1454211664] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.089999996, 0, 0) +offset = Vector2(0, -6) +pixel_size = 0.03 +texture_filter = 0 +render_priority = 6 +texture = ExtResource("5_u5sy4") + +[node name="BackArm" type="Sprite3D" parent="Player/DreamerBody/Body/ArmPivot" unique_id=1463191879] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.089999996, 0, 0) +offset = Vector2(0, -6) +pixel_size = 0.03 +texture_filter = 0 +render_priority = -1 +texture = ExtResource("5_u5sy4") + [node name="Animations" type="AnimationPlayer" parent="Player/DreamerBody" unique_id=708762765] libraries/ = SubResource("AnimationLibrary_vtaks") @@ -376,6 +639,7 @@ parameters/jump/request = 0 parameters/walk/blend_amount = 0.0 parameters/walk_speed/scale = 3.1400000000000006 parameters/fall/blend_amount = 0.0 +parameters/leap/blend_amount = 0.0 [node name="Shadow" type="Sprite3D" parent="Player" unique_id=495232250] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0) diff --git a/scripts/player.gd b/scripts/player.gd index 635ed37..08e6650 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -4,22 +4,40 @@ const SPEED = 2.5 const JUMP_VELOCITY = 4.5 var walk_animation_time = 0 +var face_rotation = null +var face_left = false @onready var game = get_parent() +@onready var camera = game.get_node("PlayerCamera") func _ready() -> void: $DreamerBody.look_at(game.get_node("PlayerCamera").global_position) $DreamerBody.rotation.x = 0 + face_rotation = $DreamerBody.rotation.y func _physics_process(delta: float) -> void: if not is_on_floor(): velocity += get_gravity() * delta - + + var viewport_size = (get_viewport().get_visible_rect().size / 2.0) + + if face_left: + $DreamerBody.rotation.y = face_rotation + deg_to_rad(180) + else: + $DreamerBody.rotation.y = face_rotation + + #$DreamerBody/Body/ArmPivot.rotation.z = viewport_size.angle_to_point(get_viewport().get_mouse_position()) + if Input.is_action_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY $DreamerBody/Animator.set("parameters/jump/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) var input_dir := Input.get_vector("move_left", "move_right", "move_up", "move_down") + if input_dir.x > 0: + face_left = false + if input_dir.x < 0: + face_left = true + var direction := (transform.basis * Vector3(input_dir.y + input_dir.x, 0, input_dir.y - input_dir.x)).normalized() if direction: velocity.x = direction.x * SPEED @@ -36,7 +54,7 @@ func _physics_process(delta: float) -> void: if direction and is_on_floor(): walk_animation_time += delta * 25 - $DreamerBody.position.y = sin(walk_animation_time + 1) / 8 + $DreamerBody.position.y = sin(walk_animation_time + 1) / 16 $DreamerBody.rotation.z = sin(walk_animation_time / 2) / 16 else: walk_animation_time = 0 @@ -47,8 +65,14 @@ func _physics_process(delta: float) -> void: if is_on_floor(): $DreamerBody/Animator.set("parameters/fall/blend_amount", 0) + $DreamerBody/Animator.set("parameters/leap/blend_amount", 0) else: - $DreamerBody/Animator.set("parameters/fall/blend_amount", 1) + if velocity.y < 0: + $DreamerBody/Animator.set("parameters/fall/blend_amount", 1) + $DreamerBody/Animator.set("parameters/leap/blend_amount", 0) + else: + $DreamerBody/Animator.set("parameters/fall/blend_amount", 0) + $DreamerBody/Animator.set("parameters/leap/blend_amount", 1) move_and_slide() diff --git a/textures/character-arm.png b/textures/character-arm.png new file mode 100644 index 0000000..acf21c5 Binary files /dev/null and b/textures/character-arm.png differ diff --git a/textures/character-arm.png.import b/textures/character-arm.png.import new file mode 100644 index 0000000..135a3c4 --- /dev/null +++ b/textures/character-arm.png.import @@ -0,0 +1,41 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rgxhw23471ut" +path.s3tc="res://.godot/imported/character-arm.png-887bc51ad4f0b012b30145a175363600.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://textures/character-arm.png" +dest_files=["res://.godot/imported/character-arm.png-887bc51ad4f0b012b30145a175363600.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/textures/example-character-hand.png b/textures/example-character-hand.png index e4c0eb8..bbe7a38 100644 Binary files a/textures/example-character-hand.png and b/textures/example-character-hand.png differ diff --git a/textures/example-character-hand.png.import b/textures/example-character-hand.png.import index 7e96405..0e4252a 100644 --- a/textures/example-character-hand.png.import +++ b/textures/example-character-hand.png.import @@ -3,19 +3,20 @@ importer="texture" type="CompressedTexture2D" uid="uid://btqaj6yslgvax" -path="res://.godot/imported/example-character-hand.png-363b3285c631aacb16602f2b09024d62.ctex" +path.s3tc="res://.godot/imported/example-character-hand.png-363b3285c631aacb16602f2b09024d62.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://textures/example-character-hand.png" -dest_files=["res://.godot/imported/example-character-hand.png-363b3285c631aacb16602f2b09024d62.ctex"] +dest_files=["res://.godot/imported/example-character-hand.png-363b3285c631aacb16602f2b09024d62.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/uastc_level=0 @@ -23,7 +24,7 @@ compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -37,4 +38,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0