Crouching
This commit is contained in:
parent
048c3ff8c1
commit
a1e1ba4fc7
|
|
@ -214,12 +214,23 @@ move_right_1={
|
|||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
crouch_1={
|
||||
"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)
|
||||
]
|
||||
}
|
||||
jump_1={
|
||||
"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":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
dash_1={
|
||||
"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":78,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
attack_1={
|
||||
"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":77,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
|
|
@ -250,12 +261,6 @@ shoot_2={
|
|||
"deadzone": 0.5,
|
||||
"events": [ ]
|
||||
}
|
||||
dash_1={
|
||||
"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":78,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,15 @@ func wants_jump() -> bool:
|
|||
_wants_jump = false
|
||||
return false
|
||||
|
||||
var _wants_crouch :bool
|
||||
func wants_crouch() -> bool:
|
||||
if Input.is_action_pressed("crouch_" + str(player_number)):
|
||||
_wants_crouch = true
|
||||
return true
|
||||
else:
|
||||
_wants_crouch = false
|
||||
return false
|
||||
|
||||
var _wants_shoot :bool
|
||||
func wants_shoot() -> bool:
|
||||
if Input.is_action_just_pressed("attack_" + str(player_number)):
|
||||
|
|
@ -88,6 +97,7 @@ func process_physics_input(delta):
|
|||
physics_delta = delta
|
||||
get_movement_direction()
|
||||
wants_jump()
|
||||
wants_crouch()
|
||||
wants_shoot()
|
||||
wants_attack_secondary()
|
||||
wants_dash()
|
||||
|
|
@ -101,6 +111,8 @@ func _state_process_physics_idle():
|
|||
if desired_movement_vector.y == UP:
|
||||
request_state_change.call_func('jump')
|
||||
|
||||
if _wants_crouch == true:
|
||||
request_state_change.call_func('crouch')
|
||||
#TODO: May need that 'bump' logic to make velocity work.
|
||||
if desired_movement_vector.x != 0: # and velocity.x != 0:
|
||||
request_state_change.call_func('move')
|
||||
|
|
@ -195,6 +207,38 @@ func _state_process_physics_move():
|
|||
|
||||
move_actor_as_desired()
|
||||
|
||||
func _state_process_physics_crouch():
|
||||
# flip sprite in direction
|
||||
flip_sprite_to_movement_direction()
|
||||
|
||||
if _wants_crouch != true:
|
||||
request_state_change.call_func('idle')
|
||||
|
||||
if !parent.is_on_floor():
|
||||
request_state_change.call_func('fall')
|
||||
|
||||
if _wants_crouch == true and desired_movement_vector.x != 0:
|
||||
request_state_change.call_func('crouch_move')
|
||||
elif desired_movement_vector.x != 0: # and velocity.x != 0:
|
||||
request_state_change.call_func('move')
|
||||
|
||||
func _state_process_physics_crouch_move():
|
||||
# flip sprite in direction
|
||||
flip_sprite_to_movement_direction()
|
||||
|
||||
if _wants_crouch != true:
|
||||
request_state_change.call_func('idle')
|
||||
|
||||
if !parent.is_on_floor():
|
||||
request_state_change.call_func('fall')
|
||||
|
||||
if _wants_crouch == true and desired_movement_vector.x == 0:
|
||||
request_state_change.call_func('crouch')
|
||||
elif _wants_crouch != true and desired_movement_vector.x != 0:
|
||||
request_state_change.call_func('move')
|
||||
|
||||
move_actor_as_desired()
|
||||
|
||||
#func _on_state_entered_idle():
|
||||
# print("Movement State Idle State Entered!")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=16 format=2]
|
||||
[gd_scene load_steps=17 format=2]
|
||||
|
||||
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
||||
|
|
@ -6,26 +6,15 @@
|
|||
[ext_resource path="res://src/actors/players/playerE/states/idle.tres" type="Resource" id=4]
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-AnimatedSprite_StateReceiver.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd" type="Script" id=6]
|
||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=7]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/move.tres" type="Resource" id=7]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/jump.tres" type="Resource" id=8]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/fall.tres" type="Resource" id=9]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/attack_sword.tres" type="Resource" id=10]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/attack_shoot.tres" type="Resource" id=11]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/land.tres" type="Resource" id=12]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/roll.tres" type="Resource" id=13]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
resource_name = "move"
|
||||
script = ExtResource( 7 )
|
||||
debug_state = false
|
||||
timeout_seconds = 0.0
|
||||
name = "move"
|
||||
horizontal_speed = 90.0
|
||||
horizontal_acceleration = 0.0
|
||||
horizontal_speed_offset = 0.0
|
||||
horizontal_speed_offset_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "run" ]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/crouch.tres" type="Resource" id=14]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/crouch_move.tres" type="Resource" id=15]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 7, 14 )
|
||||
|
|
@ -36,7 +25,7 @@ actor_type = "Player"
|
|||
|
||||
[node name="Movement_StateMachine" parent="." index="0"]
|
||||
starting_state_name = "idle"
|
||||
states = [ ExtResource( 4 ), ExtResource( 9 ), SubResource( 3 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ) ]
|
||||
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ) ]
|
||||
|
||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||
frames = ExtResource( 2 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user