Improved animations
This commit is contained in:
parent
b815a6603c
commit
3fb5ede6fa
@ -2,27 +2,27 @@ extends Node
|
|||||||
|
|
||||||
@export var character: Character
|
@export var character: Character
|
||||||
@export var animation_player: AnimationPlayer
|
@export var animation_player: AnimationPlayer
|
||||||
@export var blend_time: float
|
|
||||||
|
|
||||||
var next_animation: StringName = "RESET"
|
var next_animation: StringName = "RESET"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
assert(character)
|
assert(character)
|
||||||
assert(animation_player)
|
assert(animation_player)
|
||||||
assert(blend_time >= 0.0)
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if character.velocity.y > 0:
|
if character.velocity.y > 0:
|
||||||
play("female/jump")
|
play("human/jump")
|
||||||
|
elif character.velocity.y < 0:
|
||||||
|
play("human/falling")
|
||||||
elif character.direction != Vector3.ZERO:
|
elif character.direction != Vector3.ZERO:
|
||||||
play("female/run")
|
play("human/run")
|
||||||
else:
|
else:
|
||||||
play("female/idle")
|
play("human/idle")
|
||||||
|
|
||||||
if animation_player.current_animation == next_animation:
|
if animation_player.current_animation == next_animation:
|
||||||
return
|
return
|
||||||
|
|
||||||
animation_player.play(next_animation, blend_time)
|
animation_player.play(next_animation)
|
||||||
|
|
||||||
func play(action_name: StringName):
|
func play(action_name: StringName):
|
||||||
next_animation = action_name
|
next_animation = action_name
|
||||||
|
@ -1,25 +1,16 @@
|
|||||||
[gd_scene load_steps=11 format=3 uid="uid://2lcnu3dy54lx"]
|
[gd_scene load_steps=8 format=3 uid="uid://2lcnu3dy54lx"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"]
|
[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dnr3o1rbkqpgu" path="res://assets/models/female/Female.blend" id="2_8nah6"]
|
[ext_resource type="PackedScene" uid="uid://dnr3o1rbkqpgu" path="res://assets/models/female/Female.blend" id="2_8nah6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://character/health/HealthComponent.tscn" id="2_np5ag"]
|
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://character/health/HealthComponent.tscn" id="2_np5ag"]
|
||||||
[ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://assets/ui/font/ubuntu_nf_regular.ttf" id="4_76ehj"]
|
[ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://assets/ui/font/ubuntu_nf_regular.ttf" id="4_76ehj"]
|
||||||
[ext_resource type="Script" path="res://player/Animation.gd" id="5_d4uw4"]
|
[ext_resource type="Script" path="res://player/Animation.gd" id="5_d4uw4"]
|
||||||
[ext_resource type="Animation" uid="uid://dtjukkf6gxotr" path="res://assets/animations/idle.res" id="6_af1ii"]
|
[ext_resource type="AnimationLibrary" uid="uid://c355hn01ye2hd" path="res://assets/animations/human.blend" id="6_fl6or"]
|
||||||
[ext_resource type="Animation" uid="uid://cdff3pqukhf3q" path="res://assets/animations/run.res" id="7_23e77"]
|
|
||||||
[ext_resource type="Animation" uid="uid://dgcitda225sht" path="res://assets/animations/jump.res" id="8_v1exn"]
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"]
|
||||||
radius = 0.25
|
radius = 0.25
|
||||||
height = 1.6
|
height = 1.6
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_umd50"]
|
|
||||||
_data = {
|
|
||||||
"idle": ExtResource("6_af1ii"),
|
|
||||||
"jump": ExtResource("8_v1exn"),
|
|
||||||
"run": ExtResource("7_23e77")
|
|
||||||
}
|
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("model") groups=["player"]]
|
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("model") groups=["player"]]
|
||||||
script = ExtResource("1_8gebs")
|
script = ExtResource("1_8gebs")
|
||||||
model = NodePath("Model")
|
model = NodePath("Model")
|
||||||
@ -42,13 +33,12 @@ font = ExtResource("4_76ehj")
|
|||||||
script = ExtResource("5_d4uw4")
|
script = ExtResource("5_d4uw4")
|
||||||
character = NodePath("..")
|
character = NodePath("..")
|
||||||
animation_player = NodePath("../AnimationPlayer")
|
animation_player = NodePath("../AnimationPlayer")
|
||||||
blend_time = 0.2
|
|
||||||
|
|
||||||
[node name="Health" parent="." instance=ExtResource("2_np5ag")]
|
[node name="Health" parent="." instance=ExtResource("2_np5ag")]
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
root_node = NodePath("../Model/Female")
|
root_node = NodePath("../Model/Female")
|
||||||
libraries = {
|
libraries = {
|
||||||
"female": SubResource("AnimationLibrary_umd50")
|
"human": ExtResource("6_fl6or")
|
||||||
}
|
}
|
||||||
playback_default_blend_time = 0.2
|
playback_default_blend_time = 0.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user