mirror of
https://github.com/stevenhowes/GodotTest.git
synced 2026-05-26 15:53:30 +01:00
Basic walking (missing sprites)
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
@export var move_speed : float = 100
|
||||||
|
@export var starting_direction : Vector2 = Vector2(0,1)
|
||||||
|
|
||||||
|
@onready var animation_tree = $AnimationTree
|
||||||
|
@onready var state_machine = animation_tree.get("parameters/playback")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
update_animation_parameters(starting_direction)
|
||||||
|
|
||||||
|
func _physics_process(_delta):
|
||||||
|
var input_direction = Vector2(
|
||||||
|
Input.get_action_strength("right") - Input.get_action_strength("left"),
|
||||||
|
Input.get_action_strength("down") - Input.get_action_strength("up")
|
||||||
|
)
|
||||||
|
|
||||||
|
update_animation_parameters(input_direction)
|
||||||
|
|
||||||
|
velocity = input_direction * move_speed
|
||||||
|
|
||||||
|
pick_new_state()
|
||||||
|
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func update_animation_parameters(move_input: Vector2):
|
||||||
|
if(move_input != Vector2.ZERO):
|
||||||
|
animation_tree.set("parameters/Idle/blend_position", move_input)
|
||||||
|
animation_tree.set("parameters/Walk/blend_position", move_input)
|
||||||
|
|
||||||
|
func pick_new_state():
|
||||||
|
if(velocity != Vector2.ZERO):
|
||||||
|
state_machine.travel("Walk")
|
||||||
|
else:
|
||||||
|
state_machine.travel("Idle")
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
[gd_scene load_steps=28 format=3 uid="uid://bn6l8gpt3e2cc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Characters/player_boimler.gd" id="1_4xsm0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c2ox6qx00um5f" path="res://Sprites/boimler.png" id="1_sm1i4"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f68x6"]
|
||||||
|
size = Vector2(15, 23)
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_we2gy"]
|
||||||
|
resource_name = "walk_right"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [16, 17, 18, 19, 20]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_cvcr0"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [16]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_gncbx"]
|
||||||
|
resource_name = "idle_right"
|
||||||
|
length = 3.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 2.9),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [14, 15]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_isqws"]
|
||||||
|
resource_name = "idle_left"
|
||||||
|
length = 3.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 2.9),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [21, 22]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_uh0nl"]
|
||||||
|
resource_name = "walk_left"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [23, 24, 25, 26, 27]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_aqig2"]
|
||||||
|
resource_name = "walk_down"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [9, 10, 11, 12, 13]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_odiyi"]
|
||||||
|
resource_name = "walk_up"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [9, 10, 11, 12, 13]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_shhac"]
|
||||||
|
resource_name = "idle_down"
|
||||||
|
length = 3.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 2.9),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [7, 8]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_vg36w"]
|
||||||
|
resource_name = "idle_up"
|
||||||
|
length = 3.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 2.9),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_1a573"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_cvcr0"),
|
||||||
|
"idle_down": SubResource("Animation_shhac"),
|
||||||
|
"idle_left": SubResource("Animation_isqws"),
|
||||||
|
"idle_right": SubResource("Animation_gncbx"),
|
||||||
|
"idle_up": SubResource("Animation_vg36w"),
|
||||||
|
"walk_down": SubResource("Animation_aqig2"),
|
||||||
|
"walk_left": SubResource("Animation_uh0nl"),
|
||||||
|
"walk_right": SubResource("Animation_we2gy"),
|
||||||
|
"walk_up": SubResource("Animation_odiyi")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_24qgq"]
|
||||||
|
animation = &"idle_down"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_yowcu"]
|
||||||
|
animation = &"idle_up"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ngvgc"]
|
||||||
|
animation = &"idle_left"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_3fncq"]
|
||||||
|
animation = &"idle_right"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeBlendSpace2D" id="AnimationNodeBlendSpace2D_nqkka"]
|
||||||
|
blend_point_0/node = SubResource("AnimationNodeAnimation_24qgq")
|
||||||
|
blend_point_0/pos = Vector2(0, 1.1)
|
||||||
|
blend_point_1/node = SubResource("AnimationNodeAnimation_yowcu")
|
||||||
|
blend_point_1/pos = Vector2(0, -1.1)
|
||||||
|
blend_point_2/node = SubResource("AnimationNodeAnimation_ngvgc")
|
||||||
|
blend_point_2/pos = Vector2(-1, 0)
|
||||||
|
blend_point_3/node = SubResource("AnimationNodeAnimation_3fncq")
|
||||||
|
blend_point_3/pos = Vector2(1, 0)
|
||||||
|
min_space = Vector2(-1, -1.1)
|
||||||
|
max_space = Vector2(1, 1.1)
|
||||||
|
blend_mode = 1
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_cei2x"]
|
||||||
|
animation = &"walk_down"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_qo15p"]
|
||||||
|
animation = &"walk_up"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dgdnw"]
|
||||||
|
animation = &"walk_left"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_nbcxn"]
|
||||||
|
animation = &"walk_right"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeBlendSpace2D" id="AnimationNodeBlendSpace2D_idnn4"]
|
||||||
|
blend_point_0/node = SubResource("AnimationNodeAnimation_cei2x")
|
||||||
|
blend_point_0/pos = Vector2(0, 1.1)
|
||||||
|
blend_point_1/node = SubResource("AnimationNodeAnimation_qo15p")
|
||||||
|
blend_point_1/pos = Vector2(0, -1.1)
|
||||||
|
blend_point_2/node = SubResource("AnimationNodeAnimation_dgdnw")
|
||||||
|
blend_point_2/pos = Vector2(-1, 0)
|
||||||
|
blend_point_3/node = SubResource("AnimationNodeAnimation_nbcxn")
|
||||||
|
blend_point_3/pos = Vector2(1, 0)
|
||||||
|
min_space = Vector2(-1, -1.1)
|
||||||
|
max_space = Vector2(1, 1.1)
|
||||||
|
blend_mode = 1
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_nxanf"]
|
||||||
|
advance_mode = 0
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_acl43"]
|
||||||
|
advance_mode = 0
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xfad2"]
|
||||||
|
advance_mode = 2
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_wgkrf"]
|
||||||
|
states/Idle/node = SubResource("AnimationNodeBlendSpace2D_nqkka")
|
||||||
|
states/Idle/position = Vector2(354, 100)
|
||||||
|
states/Walk/node = SubResource("AnimationNodeBlendSpace2D_idnn4")
|
||||||
|
states/Walk/position = Vector2(488, 100)
|
||||||
|
transitions = ["Idle", "Walk", SubResource("AnimationNodeStateMachineTransition_nxanf"), "Walk", "Idle", SubResource("AnimationNodeStateMachineTransition_acl43"), "Start", "Idle", SubResource("AnimationNodeStateMachineTransition_xfad2")]
|
||||||
|
|
||||||
|
[node name="PlayerBoimler" type="CharacterBody2D"]
|
||||||
|
script = ExtResource("1_4xsm0")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = ExtResource("1_sm1i4")
|
||||||
|
hframes = 7
|
||||||
|
vframes = 4
|
||||||
|
frame = 16
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
position = Vector2(-0.5, 16.5)
|
||||||
|
shape = SubResource("RectangleShape2D_f68x6")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_1a573")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||||
|
tree_root = SubResource("AnimationNodeStateMachine_wgkrf")
|
||||||
|
anim_player = NodePath("../AnimationPlayer")
|
||||||
|
active = true
|
||||||
|
parameters/Idle/blend_position = Vector2(0, -1)
|
||||||
|
parameters/Walk/blend_position = Vector2(0, 0)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cptc8nytuwwp"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bn6l8gpt3e2cc" path="res://Characters/player_boimler.tscn" id="1_67d3u"]
|
||||||
|
|
||||||
|
[node name="TestLevel" type="Node2D"]
|
||||||
|
y_sort_enabled = true
|
||||||
|
|
||||||
|
[node name="PlayerBoimler" parent="." instance=ExtResource("1_67d3u")]
|
||||||
|
position = Vector2(78, 59)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c2ox6qx00um5f"
|
||||||
|
path="res://.godot/imported/boimler.png-9782fcbd06a714d849d351cfc471561b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/boimler.png"
|
||||||
|
dest_files=["res://.godot/imported/boimler.png-9782fcbd06a714d849d351cfc471561b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
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=1
|
||||||
@@ -11,9 +11,42 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="GodotTest"
|
config/name="GodotTest"
|
||||||
|
run/main_scene="res://Maps/test_level.tscn"
|
||||||
config/features=PackedStringArray("4.1", "Forward Plus")
|
config/features=PackedStringArray("4.1", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
window/stretch/scale=2.0
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|
||||||
project/assembly_name="GodotTest"
|
project/assembly_name="GodotTest"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
|||||||
Reference in New Issue
Block a user