Included ducking/sliding and switched to anim tree
This commit is contained in:
parent
59e87c846a
commit
bf40a26afe
@ -136,8 +136,9 @@ boost_move={
|
|||||||
}
|
}
|
||||||
duck={
|
duck={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":83,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,9 @@ func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2:
|
|||||||
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
|
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
|
||||||
return calculate_jump_velocity(velocity, delta, direction)
|
return calculate_jump_velocity(velocity, delta, direction)
|
||||||
|
|
||||||
|
func handle_duck_movement(delta: float, direction: Vector2) -> Vector2:
|
||||||
|
return calculate_duck_velocity(velocity, delta, direction)
|
||||||
|
|
||||||
|
|
||||||
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
|
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
|
||||||
return calculate_fall_velocity(velocity, delta, direction)
|
return calculate_fall_velocity(velocity, delta, direction)
|
||||||
@ -43,6 +46,71 @@ func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
|
|||||||
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
|
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
|
||||||
return calculate_wallslide_velocity(velocity, delta, direction)
|
return calculate_wallslide_velocity(velocity, delta, direction)
|
||||||
|
|
||||||
|
func calculate_duck_velocity(
|
||||||
|
linear_velocity: Vector2, delta: float, direction: Vector2
|
||||||
|
) -> Vector2:
|
||||||
|
var state = player_state_machine.state
|
||||||
|
var out_vel := linear_velocity
|
||||||
|
var velocity_direction = 1.0
|
||||||
|
if velocity.x < 0:
|
||||||
|
velocity_direction = -1.0
|
||||||
|
|
||||||
|
# TODO This is essential for the duck/sliding mechanic
|
||||||
|
var deceleration_force = calculate_deceleration_force(_gravity, mass)*0.333
|
||||||
|
|
||||||
|
# Slowing down movement when not controlling direction
|
||||||
|
if is_equal_approx(direction.x, 0):
|
||||||
|
# TODO Handle Deadzones
|
||||||
|
out_vel.x = PhysicsFunc.two_step_euler(
|
||||||
|
out_vel.x, deceleration_force * -1 * velocity_direction, mass, delta
|
||||||
|
)
|
||||||
|
if abs(out_vel.x) > abs(velocity.x):
|
||||||
|
out_vel.x = 0
|
||||||
|
else:
|
||||||
|
# Reversing movement
|
||||||
|
# When turning the opposite direction, friction is added to the opposite acceleration movement
|
||||||
|
var reverse_move = is_reversing_horizontal_movement(direction)
|
||||||
|
if reverse_move:
|
||||||
|
# TODO dont put constants in here
|
||||||
|
out_vel.x = PhysicsFunc.two_step_euler(
|
||||||
|
out_vel.x,
|
||||||
|
deceleration_force * -3.42 * velocity_direction,
|
||||||
|
mass,
|
||||||
|
delta
|
||||||
|
)
|
||||||
|
# Normal movement
|
||||||
|
if abs(velocity.x) < max_velocity[state]:
|
||||||
|
out_vel.x = PhysicsFunc.two_step_euler(
|
||||||
|
out_vel.x,
|
||||||
|
(
|
||||||
|
(
|
||||||
|
acceleration_force[state].x
|
||||||
|
+ (
|
||||||
|
init_acceleration_force[init_boost_type]
|
||||||
|
* int(init_boost)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
* direction.x
|
||||||
|
),
|
||||||
|
mass,
|
||||||
|
delta
|
||||||
|
)
|
||||||
|
elif !reverse_move:
|
||||||
|
out_vel.x = max_velocity[state] * direction.x
|
||||||
|
# Jumping when grounded or jump is buffered
|
||||||
|
if (
|
||||||
|
Input.is_action_just_pressed("jump")
|
||||||
|
|| (jump_buffer_filled && is_on_floor())
|
||||||
|
):
|
||||||
|
return calculate_jump_velocity(velocity, delta, direction)
|
||||||
|
|
||||||
|
elif player_state_machine.coyote_hanging:
|
||||||
|
out_vel.y = 0
|
||||||
|
|
||||||
|
else:
|
||||||
|
out_vel.y = _gravity * delta
|
||||||
|
|
||||||
|
return out_vel
|
||||||
|
|
||||||
func calculate_grounded_velocity(
|
func calculate_grounded_velocity(
|
||||||
linear_velocity: Vector2, delta: float, direction: Vector2
|
linear_velocity: Vector2, delta: float, direction: Vector2
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=12 format=2]
|
[gd_scene load_steps=49 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/Actors/Blobby/BlobbyCam.gd" type="Script" id=2]
|
[ext_resource path="res://src/Actors/Blobby/BlobbyCam.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://src/Actors/Blobby/BlobbyStateMachine.gd" type="Script" id=3]
|
[ext_resource path="res://src/Actors/Blobby/BlobbyStateMachine.gd" type="Script" id=3]
|
||||||
@ -11,29 +11,122 @@ extents = Vector2( 13, 9 )
|
|||||||
[sub_resource type="StreamTexture" id=5]
|
[sub_resource type="StreamTexture" id=5]
|
||||||
load_path = "res://.import/Blobby.png-42eed5028ccb56a7415a0793b79ec61e.stex"
|
load_path = "res://.import/Blobby.png-42eed5028ccb56a7415a0793b79ec61e.stex"
|
||||||
|
|
||||||
[sub_resource type="Animation" id=6]
|
[sub_resource type="AnimationNodeAnimation" id=18]
|
||||||
length = 0.1
|
animation = "ducking"
|
||||||
loop = true
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=19]
|
||||||
|
animation = "falling"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=20]
|
||||||
|
animation = "idling"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=21]
|
||||||
|
animation = "idling"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=22]
|
||||||
|
animation = "jumping"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=23]
|
||||||
|
animation = "running"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=24]
|
||||||
|
animation = "walking"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=25]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=26]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=27]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=28]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=29]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=30]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=31]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=32]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=33]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=34]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=35]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=36]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=37]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=38]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=39]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=40]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=41]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=42]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=43]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=44]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=45]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=46]
|
||||||
|
switch_mode = 2
|
||||||
|
auto_advance = true
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=50]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=51]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=52]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachine" id=47]
|
||||||
|
states/ducking/node = SubResource( 18 )
|
||||||
|
states/ducking/position = Vector2( 652, 205 )
|
||||||
|
states/falling/node = SubResource( 19 )
|
||||||
|
states/falling/position = Vector2( 1097, 241 )
|
||||||
|
states/idling/node = SubResource( 21 )
|
||||||
|
states/idling/position = Vector2( 356, 38 )
|
||||||
|
"states/idling 2/node" = SubResource( 20 )
|
||||||
|
"states/idling 2/position" = Vector2( 652, 657.74 )
|
||||||
|
states/jumping/node = SubResource( 22 )
|
||||||
|
states/jumping/position = Vector2( 203, 265 )
|
||||||
|
states/running/node = SubResource( 23 )
|
||||||
|
states/running/position = Vector2( 991, 38 )
|
||||||
|
states/walking/node = SubResource( 24 )
|
||||||
|
states/walking/position = Vector2( 652, 525 )
|
||||||
|
transitions = [ "idling", "walking", SubResource( 25 ), "walking", "idling", SubResource( 26 ), "idling", "running", SubResource( 27 ), "running", "idling", SubResource( 28 ), "running", "walking", SubResource( 29 ), "walking", "running", SubResource( 30 ), "idling", "jumping", SubResource( 31 ), "running", "jumping", SubResource( 32 ), "walking", "jumping", SubResource( 33 ), "ducking", "idling", SubResource( 34 ), "idling", "ducking", SubResource( 35 ), "ducking", "running", SubResource( 36 ), "running", "ducking", SubResource( 37 ), "walking", "ducking", SubResource( 38 ), "ducking", "walking", SubResource( 39 ), "falling", "running", SubResource( 40 ), "falling", "ducking", SubResource( 41 ), "falling", "idling", SubResource( 42 ), "falling", "walking", SubResource( 43 ), "ducking", "jumping", SubResource( 44 ), "jumping", "idling 2", SubResource( 45 ), "idling 2", "falling", SubResource( 46 ), "walking", "falling", SubResource( 50 ), "running", "falling", SubResource( 51 ), "ducking", "falling", SubResource( 52 ) ]
|
||||||
|
start_node = "idling"
|
||||||
|
graph_offset = Vector2( -114.671, -66.5935 )
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachinePlayback" id=48]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=17]
|
||||||
|
length = 0.001
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath(".:frame")
|
tracks/0/path = NodePath(".:frame")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
tracks/0/loop_wrap = false
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
"times": PoolRealArray( 0 ),
|
"times": PoolRealArray( 0 ),
|
||||||
"transitions": PoolRealArray( 1 ),
|
"transitions": PoolRealArray( 1 ),
|
||||||
"update": 1,
|
"update": 0,
|
||||||
"values": [ 7.0 ]
|
"values": [ 5 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=7]
|
[sub_resource type="Animation" id=12]
|
||||||
|
resource_name = "ducking"
|
||||||
length = 0.1
|
length = 0.1
|
||||||
loop = true
|
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath(".:frame")
|
tracks/0/path = NodePath(".:frame")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
tracks/0/loop_wrap = false
|
tracks/0/loop_wrap = true
|
||||||
tracks/0/imported = false
|
tracks/0/imported = false
|
||||||
tracks/0/enabled = true
|
tracks/0/enabled = true
|
||||||
tracks/0/keys = {
|
tracks/0/keys = {
|
||||||
@ -43,9 +136,50 @@ tracks/0/keys = {
|
|||||||
"values": [ 5.0 ]
|
"values": [ 5.0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=6]
|
||||||
|
length = 0.1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath(".:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 7.0 ]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/path = NodePath(".:hframes")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PoolRealArray( 0 ),
|
||||||
|
"transitions": PoolRealArray( 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 3 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=7]
|
||||||
|
length = 0.1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath(".:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0.0166506, 0.149976, 0.174978, 0.391648, 0.541643, 0.799974 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1 ),
|
||||||
|
"update": 0,
|
||||||
|
"values": [ 5, 5, 5, 5, 5, 5 ]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=8]
|
[sub_resource type="Animation" id=8]
|
||||||
length = 0.1
|
length = 0.1
|
||||||
loop = true
|
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath(".:frame")
|
tracks/0/path = NodePath(".:frame")
|
||||||
tracks/0/interp = 1
|
tracks/0/interp = 1
|
||||||
@ -59,8 +193,25 @@ tracks/0/keys = {
|
|||||||
"values": [ 6.0 ]
|
"values": [ 6.0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=49]
|
||||||
|
resource_name = "running"
|
||||||
|
length = 0.3
|
||||||
|
loop = true
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/path = NodePath(".:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = false
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PoolRealArray( 0, 0.07, 0.14, 0.21, 0.28 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0.0, 1.0, 2.0, 4.0, 4.0 ]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=9]
|
[sub_resource type="Animation" id=9]
|
||||||
length = 0.5
|
length = 0.45
|
||||||
loop = true
|
loop = true
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath(".:frame")
|
tracks/0/path = NodePath(".:frame")
|
||||||
@ -97,15 +248,26 @@ position = Vector2( 0, -16 )
|
|||||||
texture = SubResource( 5 )
|
texture = SubResource( 5 )
|
||||||
hframes = 3
|
hframes = 3
|
||||||
vframes = 3
|
vframes = 3
|
||||||
|
frame = 5
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUJsb2JieVNwcml0ZS9CbG9iYnltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvYmxvYmJ5L2Jsb2JieS1zcHJpdGVzaGVldHQuYXNlcHJpdGUKbGF5ZXJ8PUJsb2JieQpvcF9leHB8PUZhbHNlCm9fZm9sZGVyfD0Kb19uYW1lfD0Kb25seV92aXNpYmxlfD1GYWxzZQpvX2V4X3B8PQo="
|
"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUJsb2JieVNwcml0ZS9CbG9iYnltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvYmxvYmJ5L2Jsb2JieS1zcHJpdGVzaGVldHQuYXNlcHJpdGUKbGF5ZXJ8PUJsb2JieQpvcF9leHB8PUZhbHNlCm9fZm9sZGVyfD0Kb19uYW1lfD0Kb25seV92aXNpYmxlfD1GYWxzZQpvX2V4X3B8PQo="
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="AnimationTree" type="AnimationTree" parent="BlobbySprite"]
|
||||||
|
tree_root = SubResource( 47 )
|
||||||
|
anim_player = NodePath("../BlobbymationPlayer")
|
||||||
|
active = true
|
||||||
|
root_motion_track = NodePath(".:frame")
|
||||||
|
parameters/playback = SubResource( 48 )
|
||||||
|
|
||||||
[node name="BlobbymationPlayer" type="AnimationPlayer" parent="BlobbySprite"]
|
[node name="BlobbymationPlayer" type="AnimationPlayer" parent="BlobbySprite"]
|
||||||
playback_process_mode = 0
|
playback_process_mode = 0
|
||||||
|
anims/RESET = SubResource( 17 )
|
||||||
|
anims/ducking = SubResource( 12 )
|
||||||
anims/falling = SubResource( 6 )
|
anims/falling = SubResource( 6 )
|
||||||
anims/idling = SubResource( 7 )
|
anims/idling = SubResource( 7 )
|
||||||
anims/jumping = SubResource( 8 )
|
anims/jumping = SubResource( 8 )
|
||||||
|
anims/running = SubResource( 49 )
|
||||||
anims/walking = SubResource( 9 )
|
anims/walking = SubResource( 9 )
|
||||||
|
|
||||||
[node name="BlobbyBody" type="CollisionShape2D" parent="." groups=["player"]]
|
[node name="BlobbyBody" type="CollisionShape2D" parent="." groups=["player"]]
|
||||||
@ -133,9 +295,6 @@ script = ExtResource( 2 )
|
|||||||
|
|
||||||
[node name="BlobbyStateMachine" type="Node" parent="."]
|
[node name="BlobbyStateMachine" type="Node" parent="."]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
coyote_hanging = null
|
|
||||||
init_boost = null
|
|
||||||
init_boost_type = null
|
|
||||||
|
|
||||||
[node name="JumpBufferTimer" type="Timer" parent="BlobbyStateMachine"]
|
[node name="JumpBufferTimer" type="Timer" parent="BlobbyStateMachine"]
|
||||||
wait_time = 0.067
|
wait_time = 0.067
|
||||||
|
|||||||
@ -5,9 +5,10 @@ signal got_grounded
|
|||||||
onready var coyoteTimer = $CoyoteTimer
|
onready var coyoteTimer = $CoyoteTimer
|
||||||
export var coyote_hanging = false
|
export var coyote_hanging = false
|
||||||
export var init_boost = false
|
export var init_boost = false
|
||||||
export var init_boost_type = "idle_walk"
|
export var init_boost_type = ""
|
||||||
onready var jumpBufferTimer = $JumpBufferTimer
|
onready var jumpBufferTimer = $JumpBufferTimer
|
||||||
onready var anim_player = parent.get_node("BlobbySprite/BlobbymationPlayer")
|
onready var anim_player = parent.get_node("BlobbySprite/BlobbymationPlayer")
|
||||||
|
onready var anim_statemachine = parent.get_node("BlobbySprite/AnimationTree").get("parameters/playback")
|
||||||
onready var sprite = parent.get_node("BlobbySprite")
|
onready var sprite = parent.get_node("BlobbySprite")
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +23,6 @@ func _ready():
|
|||||||
add_state("wallslide")
|
add_state("wallslide")
|
||||||
state = states.idle
|
state = states.idle
|
||||||
set_state(states.idle)
|
set_state(states.idle)
|
||||||
anim_player.play("idling")
|
|
||||||
|
|
||||||
|
|
||||||
# Calls the parent behaviours according to state
|
# Calls the parent behaviours according to state
|
||||||
@ -57,6 +57,7 @@ func _state_logic(delta):
|
|||||||
print("don't panik")
|
print("don't panik")
|
||||||
|
|
||||||
var direction = get_horizontal_direction()
|
var direction = get_horizontal_direction()
|
||||||
|
|
||||||
if direction.x < 0:
|
if direction.x < 0:
|
||||||
sprite.flip_h = true
|
sprite.flip_h = true
|
||||||
elif direction.x > 0:
|
elif direction.x > 0:
|
||||||
@ -146,14 +147,16 @@ func _get_transition(_delta):
|
|||||||
elif parent.velocity.x != 0:
|
elif parent.velocity.x != 0:
|
||||||
if Input.is_action_pressed("boost_move"):
|
if Input.is_action_pressed("boost_move"):
|
||||||
new_state = states.run
|
new_state = states.run
|
||||||
elif Input.is_action_just_pressed("duck"):
|
|
||||||
new_state = states.duck
|
|
||||||
else:
|
else:
|
||||||
new_state = states.walk
|
new_state = states.walk
|
||||||
|
if Input.is_action_pressed("duck"):
|
||||||
|
new_state = states.duck
|
||||||
coyote_hanging = false
|
coyote_hanging = false
|
||||||
|
|
||||||
else:
|
else:
|
||||||
new_state = states.idle
|
new_state = states.idle
|
||||||
|
if Input.is_action_pressed("duck"):
|
||||||
|
new_state = states.duck
|
||||||
coyote_hanging = false
|
coyote_hanging = false
|
||||||
if new_state != self.state:
|
if new_state != self.state:
|
||||||
return new_state
|
return new_state
|
||||||
@ -165,24 +168,34 @@ func _enter_state(new_state, old_state):
|
|||||||
if old_state == "idle" && (new_state == "walk" || new_state == "run"):
|
if old_state == "idle" && (new_state == "walk" || new_state == "run"):
|
||||||
init_boost = true
|
init_boost = true
|
||||||
init_boost_type = old_state + "_" + new_state
|
init_boost_type = old_state + "_" + new_state
|
||||||
|
else:
|
||||||
|
init_boost = false
|
||||||
|
init_boost_type = ""
|
||||||
|
|
||||||
if !["run", "walk", "idle"].has(old_state) && parent.is_on_floor():
|
if !["run", "walk", "idle", "duck"].has(old_state) && parent.is_on_floor():
|
||||||
emit_signal("got_grounded")
|
emit_signal("got_grounded")
|
||||||
|
|
||||||
|
|
||||||
match new_state:
|
match new_state:
|
||||||
states.walk:
|
states.walk:
|
||||||
anim_player.play("walking")
|
anim_statemachine.travel("walking")
|
||||||
states.idle:
|
states.idle:
|
||||||
anim_player.play("idling")
|
anim_statemachine.travel("idling")
|
||||||
|
states.duck:
|
||||||
|
# TODO HA! H! HAAA!
|
||||||
|
parent.scale = Vector2(1.2, 0.5)
|
||||||
|
anim_statemachine.travel("ducking")
|
||||||
states.jump:
|
states.jump:
|
||||||
anim_player.play("jumping")
|
anim_statemachine.travel("jumping")
|
||||||
states.fall:
|
states.fall:
|
||||||
anim_player.get_animation("idling").loop = false
|
anim_statemachine.travel("falling")
|
||||||
anim_player.play("idling")
|
|
||||||
anim_player.queue("falling")
|
|
||||||
states.run:
|
states.run:
|
||||||
anim_player.play("walking", -1, 1.33)
|
anim_statemachine.travel("running")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _exit_state(old_state, new_state):
|
func _exit_state(old_state, new_state):
|
||||||
|
match old_state:
|
||||||
|
states.duck:
|
||||||
|
parent.scale = Vector2(1, 1)
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -17,7 +17,6 @@ func _on_StompDetector_body_entered(body: Node) -> void:
|
|||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
velocity.y += _gravity * delta
|
velocity.y += _gravity * delta
|
||||||
velocity.x = 80 * player_on_floor_direction()
|
velocity.x = 80 * player_on_floor_direction()
|
||||||
print(velocity.x)
|
|
||||||
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
|
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
|
||||||
|
|
||||||
# TODO Detects player over gaps
|
# TODO Detects player over gaps
|
||||||
|
|||||||
@ -10,18 +10,19 @@ var wallslide_threshold := 1000
|
|||||||
var base_floor_friction := 0.5
|
var base_floor_friction := 0.5
|
||||||
var floor_friction := base_floor_friction
|
var floor_friction := base_floor_friction
|
||||||
var max_velocity := {
|
var max_velocity := {
|
||||||
"walk": 120, "run": 160, "fall": 420, "walljump": 200, "idle": 12000
|
"walk": 120, "run": 160, "fall": 420, "walljump": 200, "idle": 12000, "duck": 200
|
||||||
}
|
}
|
||||||
var velocity_jump_boost_ratio := 10
|
var velocity_jump_boost_ratio := 10
|
||||||
# This is added to the acceleration force initially
|
# This is added to the acceleration force initially
|
||||||
var init_acceleration_force := {
|
var init_acceleration_force := {
|
||||||
"idle_walk": 4181, "idle_run": 5765, "walk_run": 1000
|
"": 0, "idle_walk": 4181, "idle_run": 5765, "walk_run": 1000
|
||||||
}
|
}
|
||||||
# Oriented around deltas of 0.0166666...s
|
# Oriented around deltas of 0.0166666...s
|
||||||
# newtonmeters is the unit
|
# newtonmeters is the unit
|
||||||
var acceleration_force := {
|
var acceleration_force := {
|
||||||
"walk": Vector2(1800, 1233),
|
"walk": Vector2(1800, 1233),
|
||||||
"idle": Vector2(1800, 1233),
|
"idle": Vector2(1800, 1233),
|
||||||
|
"duck": Vector2(1000, 1500),
|
||||||
"run": Vector2(2500, 1290),
|
"run": Vector2(2500, 1290),
|
||||||
"walljump": Vector2(600, 1050),
|
"walljump": Vector2(600, 1050),
|
||||||
"air_strafe": Vector2(333, 2000)
|
"air_strafe": Vector2(333, 2000)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user