add initial slide animation
This commit is contained in:
parent
2bb8f23377
commit
40b8d0a806
@ -3,6 +3,8 @@ class_name Character
|
||||
|
||||
signal turn(direction: TileTurn.Direction)
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer as AnimationPlayer
|
||||
|
||||
@export var speed: float = 20.0
|
||||
@export var jump_height: float = 3
|
||||
@export var tile: Tile
|
||||
@ -12,9 +14,11 @@ var current_height: float = 0.0
|
||||
var jump_tween: Tween
|
||||
var fall_tween: Tween
|
||||
var in_air: bool = false
|
||||
var sliding: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
animation_player.animation_finished.connect(_animation_finished)
|
||||
if tile == null or tile is not Tile:
|
||||
printerr("tile is not set to a Tile")
|
||||
return
|
||||
@ -30,6 +34,8 @@ func _process(delta: float) -> void:
|
||||
turn.emit(TileTurn.Direction.Left)
|
||||
if Input.is_action_just_pressed("ui_up"):
|
||||
jump()
|
||||
if Input.is_action_just_pressed("ui_down"):
|
||||
slide()
|
||||
|
||||
global_position = tile.marker_position
|
||||
global_rotation = tile.marker_rotation
|
||||
@ -41,7 +47,7 @@ func _process(delta: float) -> void:
|
||||
tile.follow.v_offset = current_height
|
||||
|
||||
|
||||
func _on_area_entered(area):
|
||||
func _on_area_entered(area: Area3D) -> void:
|
||||
if area is Obstacle:
|
||||
handle_obstacle(area)
|
||||
|
||||
@ -53,7 +59,7 @@ func handle_obstacle(obstacle: Obstacle) -> void:
|
||||
|
||||
|
||||
func jump() -> void:
|
||||
if in_air:
|
||||
if in_air or sliding:
|
||||
return
|
||||
in_air = true
|
||||
jump_tween = get_tree().create_tween()
|
||||
@ -68,3 +74,15 @@ func fall() -> void:
|
||||
|
||||
func finish_falling() -> void:
|
||||
in_air = false
|
||||
|
||||
|
||||
func slide() -> void:
|
||||
if in_air or sliding:
|
||||
return
|
||||
sliding = true
|
||||
animation_player.play("slide")
|
||||
|
||||
|
||||
func _animation_finished(animation_name: String) -> void:
|
||||
if animation_name == "slide":
|
||||
sliding = false
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://vamte52rvfhy"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://vamte52rvfhy"]
|
||||
|
||||
[ext_resource type="Script" path="res://character/character.gd" id="1_evtr0"]
|
||||
|
||||
@ -6,11 +6,59 @@
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_br0ui"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_3gdgw"]
|
||||
resource_name = "slide"
|
||||
length = 1.1
|
||||
tracks/0/type = "rotation_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MeshInstance3D")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 0, 0, 0, 1, 0.0001, 1, 0, 0, 0, 1, 0.3, 1, 0.707107, 0, 0, 0.707107, 0.8, 1, 0.707107, 0, 0, 0.707107, 1.1, 1, 0, 0, 0, 1)
|
||||
tracks/1/type = "position_3d"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("MeshInstance3D")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = PackedFloat32Array(0, 1, 0, 1, 0, 0.3, 1, 0, 0.511, 0.7, 0.8, 1, 0, 0.511, 0.7, 1.1, 1, 0, 1, 0)
|
||||
tracks/2/type = "rotation_3d"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("CollisionShape3D")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = PackedFloat32Array(-2.23517e-08, 1, 0, 0, 0, 1, 9.99793e-05, 1, 0, 0, 0, 1, 0.3, 1, 0.707107, 0, 0, 0.707107, 0.8, 1, 0.707107, 0, 0, 0.707107, 1.1, 1, 0, 0, 0, 1)
|
||||
tracks/3/type = "position_3d"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("CollisionShape3D")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = PackedFloat32Array(-2.23517e-08, 1, 0, 1, 0, 0.3, 1, 0, 0.511, 0.7, 0.8, 1, 0, 0.511, 0.7, 1.1, 1, 0, 1, 0)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_tu0ui"]
|
||||
length = 0.001
|
||||
tracks/0/type = "rotation_3d"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("MeshInstance3D")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = PackedFloat32Array(0, 1, 0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_w1708"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_tu0ui"),
|
||||
"slide": SubResource("Animation_3gdgw")
|
||||
}
|
||||
|
||||
[node name="Character" type="Area3D"]
|
||||
script = ExtResource("1_evtr0")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 5.21541e-08)
|
||||
shape = SubResource("CapsuleShape3D_gnhao")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
@ -21,4 +69,9 @@ skeleton = NodePath("")
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, -4.52535e-08, 1.68888e-07, -1.77636e-15, 0.965926, 0.258819, -1.74846e-07, -0.258819, 0.965926, 0, 2, 2.558)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_w1708")
|
||||
}
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||
|
Loading…
Reference in New Issue
Block a user