mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 05:20:06 +01:00
* Improve gamepad behaviour in rpg Fix gamepad can't do dialogue. Fix character often plays bump animation with gamepad when there's no obstacles around. Add gamepad A to ui_accept so gamepads can press buttons in dialogue and combat. Use get_vector so we get an automatic deadzone on our input. Round our input direction so we don't pass Vector2i(0,0) to request_move, get denied, and then do a bump animation. * Use SpriteFrames instead of animating texture Seems like Godot 4 doesn't allow toggling AnimationPlayer tracks by making children editable so the texture is no longer being set and the player is invisible. Regardless, this workflow is also not scalable to multiple enemy types. Instead, use SpriteFrames to setup different visuals for each slime. Triggers animations from code alongside AnimationPlayer calls because doing it in AnimationPlayer seemed unnecessarily complex. * Give all slimes a common base class Split player input handling from walker to allow both slimes to use the same visual setup. In a real game, you'd want this kind of setup so enemies are able to walk on the grid too. Remove unused actor.gd -- looks like this was an early version of walker.gd. Setup opponent slime as type=Actor because otherwise you can't fight them. * Convert TileMap to TileMapLayer Used "Extract TileMap layers as individual TileMapLayer nodes" in the TileMap editor and removed the 0 layer argument from functions in grid.gd * Explain and rename facing direction node When I first started looking into the character, I couldn't figure out what this play button texture was for. After experimenting, it might be an old version of the character visuals or a demo to show how to make your character rotate. * Fade to black between scenes Fix blue screen when entering combat. Our fade ColorRect was hidden so it never displayed. We removed the exploration scene before fading so the fade started with an empty scene with a blue skybox. * Loop idle animation in combat Add AnimationTree to combat character setup so we can tell when the take_damage animation completes. This was harder than expected because by default Godot modulates to black and sets scale to 0 unless you specify otherwise with the RESET animation. * Add a CanvasLayer above each clickable Control root Fix mouse can't click buttons. Seems like we're not able to click buttons in Godot 4 without a CanvasLayer root. Adding that makes it work, but required some restructuring to point at the correct node. In cases like combat+ui, change it to emit a signal to use the "call down, signal up" pattern. * Remove error comment that no longer occurs Neither winning nor fleeing triggers this warning on Godot v4.4.1.stable.official [49a5bc7b6]. * Rename parent -> grid Make it clearer that the parent of the player and other pawns is expected to be our Grid class.
219 lines
7.0 KiB
Plaintext
219 lines
7.0 KiB
Plaintext
[gd_scene load_steps=19 format=3 uid="uid://bdni5iw2j108j"]
|
|
|
|
[ext_resource type="Script" uid="uid://b240sdxvva6wr" path="res://grid_movement/pawns/walker.gd" id="1"]
|
|
[ext_resource type="Texture2D" uid="uid://ba5rklp7brg7" path="res://grid_movement/pawns/character.png" id="2"]
|
|
[ext_resource type="SpriteFrames" uid="uid://gucxux3cqds3" path="res://grid_movement/pawns/anim_player.tres" id="4_1c7h6"]
|
|
|
|
[sub_resource type="Animation" id="3"]
|
|
length = 0.001
|
|
|
|
[sub_resource type="Animation" id="1"]
|
|
resource_name = "bump"
|
|
length = 0.25
|
|
step = 0.01
|
|
tracks/0/type = "value"
|
|
tracks/0/imported = false
|
|
tracks/0/enabled = true
|
|
tracks/0/path = NodePath("Pivot/FacingDirection:position")
|
|
tracks/0/interp = 1
|
|
tracks/0/loop_wrap = true
|
|
tracks/0/keys = {
|
|
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25),
|
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
|
"update": 0,
|
|
"values": [Vector2(0, 0), Vector2(-0.6, -1), Vector2(1, 0.6), Vector2(-1.2, 1), Vector2(0.5, -0.5), Vector2(0, 0)]
|
|
}
|
|
tracks/1/type = "value"
|
|
tracks/1/imported = false
|
|
tracks/1/enabled = true
|
|
tracks/1/path = NodePath("Pivot/Slime:position")
|
|
tracks/1/interp = 1
|
|
tracks/1/loop_wrap = true
|
|
tracks/1/keys = {
|
|
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25),
|
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
|
"update": 0,
|
|
"values": [Vector2(0, 0), Vector2(-3, -4), Vector2(2, 1.5), Vector2(-2.6, 2), Vector2(1.8, -1.9), Vector2(0, 0)]
|
|
}
|
|
tracks/2/type = "value"
|
|
tracks/2/imported = false
|
|
tracks/2/enabled = true
|
|
tracks/2/path = NodePath("Pivot/Slime:scale")
|
|
tracks/2/interp = 1
|
|
tracks/2/loop_wrap = true
|
|
tracks/2/keys = {
|
|
"times": PackedFloat32Array(0, 0.25),
|
|
"transitions": PackedFloat32Array(1, 1),
|
|
"update": 0,
|
|
"values": [Vector2(1, 1), Vector2(1, 1)]
|
|
}
|
|
|
|
[sub_resource type="Animation" id="4"]
|
|
resource_name = "idle"
|
|
length = 1.5
|
|
loop_mode = 1
|
|
tracks/0/type = "value"
|
|
tracks/0/imported = false
|
|
tracks/0/enabled = true
|
|
tracks/0/path = NodePath("Pivot/Slime:position")
|
|
tracks/0/interp = 1
|
|
tracks/0/loop_wrap = true
|
|
tracks/0/keys = {
|
|
"times": PackedFloat32Array(0, 0.3, 0.7, 1.5),
|
|
"transitions": PackedFloat32Array(1, 0.5, 2, 1),
|
|
"update": 0,
|
|
"values": [Vector2(0, 0), Vector2(0, 5), Vector2(0, -4.498), Vector2(0, 0)]
|
|
}
|
|
tracks/1/type = "value"
|
|
tracks/1/imported = false
|
|
tracks/1/enabled = true
|
|
tracks/1/path = NodePath("Pivot/Slime:scale")
|
|
tracks/1/interp = 1
|
|
tracks/1/loop_wrap = true
|
|
tracks/1/keys = {
|
|
"times": PackedFloat32Array(0, 0.3, 0.7, 1.5),
|
|
"transitions": PackedFloat32Array(1, 0.5, 2, 1),
|
|
"update": 0,
|
|
"values": [Vector2(1, 1), Vector2(1.125, 0.844), Vector2(0.906, 1.141), Vector2(1, 1)]
|
|
}
|
|
|
|
[sub_resource type="Animation" id="2"]
|
|
resource_name = "walk"
|
|
length = 0.25
|
|
step = 0.05
|
|
tracks/0/type = "value"
|
|
tracks/0/imported = false
|
|
tracks/0/enabled = true
|
|
tracks/0/path = NodePath("Pivot/FacingDirection:self_modulate")
|
|
tracks/0/interp = 1
|
|
tracks/0/loop_wrap = true
|
|
tracks/0/keys = {
|
|
"times": PackedFloat32Array(0, 0.1, 0.25),
|
|
"transitions": PackedFloat32Array(1, 1, 1),
|
|
"update": 0,
|
|
"values": [Color(1, 1, 1, 1), Color(1, 0.9375, 0, 1), Color(1, 1, 1, 1)]
|
|
}
|
|
tracks/1/type = "value"
|
|
tracks/1/imported = false
|
|
tracks/1/enabled = true
|
|
tracks/1/path = NodePath("Pivot/FacingDirection:position")
|
|
tracks/1/interp = 1
|
|
tracks/1/loop_wrap = true
|
|
tracks/1/keys = {
|
|
"times": PackedFloat32Array(0, 0.1, 0.15, 0.25),
|
|
"transitions": PackedFloat32Array(1, 0.303143, 2.61003, 1),
|
|
"update": 0,
|
|
"values": [Vector2(1.43051e-06, -1.90735e-06), Vector2(1.43051e-06, -1.90735e-06), Vector2(0, -20), Vector2(1.43051e-06, -1.90735e-06)]
|
|
}
|
|
tracks/2/type = "value"
|
|
tracks/2/imported = false
|
|
tracks/2/enabled = true
|
|
tracks/2/path = NodePath("Pivot/FacingDirection:scale")
|
|
tracks/2/interp = 1
|
|
tracks/2/loop_wrap = true
|
|
tracks/2/keys = {
|
|
"times": PackedFloat32Array(0, 0.05, 0.15, 0.25),
|
|
"transitions": PackedFloat32Array(1, 0.354553, 1, 1),
|
|
"update": 0,
|
|
"values": [Vector2(1, 1), Vector2(1.20007, 0.917384), Vector2(0.916712, 1.13495), Vector2(1, 1)]
|
|
}
|
|
tracks/3/type = "value"
|
|
tracks/3/imported = false
|
|
tracks/3/enabled = true
|
|
tracks/3/path = NodePath("Pivot/Slime:position")
|
|
tracks/3/interp = 1
|
|
tracks/3/loop_wrap = true
|
|
tracks/3/keys = {
|
|
"times": PackedFloat32Array(0, 0.1, 0.15, 0.25),
|
|
"transitions": PackedFloat32Array(1, 0.378929, 2.63902, 1),
|
|
"update": 0,
|
|
"values": [Vector2(0, 0), Vector2(0, 0), Vector2(0, -20), Vector2(0, 0)]
|
|
}
|
|
tracks/4/type = "value"
|
|
tracks/4/imported = false
|
|
tracks/4/enabled = true
|
|
tracks/4/path = NodePath("Pivot/Slime:scale")
|
|
tracks/4/interp = 1
|
|
tracks/4/loop_wrap = true
|
|
tracks/4/keys = {
|
|
"times": PackedFloat32Array(0, 0.05, 0.15, 0.25),
|
|
"transitions": PackedFloat32Array(1, 0.353553, 1, 1),
|
|
"update": 0,
|
|
"values": [Vector2(1, 1), Vector2(1.2, 0.917), Vector2(0.917, 1.135), Vector2(1, 1)]
|
|
}
|
|
|
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_yxglf"]
|
|
_data = {
|
|
&"RESET": SubResource("3"),
|
|
&"bump": SubResource("1"),
|
|
&"idle": SubResource("4"),
|
|
&"walk": SubResource("2")
|
|
}
|
|
|
|
[sub_resource type="AnimationNodeAnimation" id="9"]
|
|
animation = &"bump"
|
|
|
|
[sub_resource type="AnimationNodeAnimation" id="7"]
|
|
animation = &"idle"
|
|
|
|
[sub_resource type="AnimationNodeAnimation" id="10"]
|
|
animation = &"walk"
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="11"]
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="12"]
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="13"]
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="14"]
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ed7tp"]
|
|
advance_mode = 2
|
|
|
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_j3wgi"]
|
|
advance_mode = 0
|
|
|
|
[sub_resource type="AnimationNodeStateMachine" id="5"]
|
|
states/End/position = Vector2(245, -15)
|
|
states/Start/position = Vector2(-22, 84)
|
|
states/bump/node = SubResource("9")
|
|
states/bump/position = Vector2(139, 194)
|
|
states/idle/node = SubResource("7")
|
|
states/idle/position = Vector2(139, 36)
|
|
states/walk/node = SubResource("10")
|
|
states/walk/position = Vector2(310, 116)
|
|
transitions = ["walk", "idle", SubResource("11"), "bump", "idle", SubResource("12"), "idle", "walk", SubResource("13"), "idle", "bump", SubResource("14"), "Start", "idle", SubResource("AnimationNodeStateMachineTransition_ed7tp"), "idle", "End", SubResource("AnimationNodeStateMachineTransition_j3wgi")]
|
|
graph_offset = Vector2(-609, -158)
|
|
|
|
[node name="Character" type="Node2D"]
|
|
z_index = 1
|
|
script = ExtResource("1")
|
|
|
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
|
libraries = {
|
|
&"": SubResource("AnimationLibrary_yxglf")
|
|
}
|
|
|
|
[node name="Pivot" type="Marker2D" parent="."]
|
|
|
|
[node name="Slime" type="AnimatedSprite2D" parent="Pivot"]
|
|
position = Vector2(0, -3.21718)
|
|
scale = Vector2(0.932767, 1.10085)
|
|
sprite_frames = ExtResource("4_1c7h6")
|
|
animation = &"idle"
|
|
centered = false
|
|
offset = Vector2(-32, -32)
|
|
|
|
[node name="FacingDirection" type="Sprite2D" parent="Pivot"]
|
|
editor_description = "Enable this node to see the character's facing direction."
|
|
visible = false
|
|
self_modulate = Color(0, 0, 0, 1)
|
|
scale = Vector2(1e-05, 1e-05)
|
|
texture = ExtResource("2")
|
|
centered = false
|
|
offset = Vector2(-32, -32)
|
|
|
|
[node name="AnimationTree" type="AnimationTree" parent="."]
|
|
tree_root = SubResource("5")
|
|
anim_player = NodePath("../AnimationPlayer")
|