Starting to learn to climb ladders.
This commit is contained in:
parent
3f19a92db6
commit
6f8a13c8bb
|
|
@ -221,6 +221,7 @@ dash_1={
|
|||
2d_physics/layer_6="EnemyHurtbox"
|
||||
2d_physics/layer_7="PlayerHitbox"
|
||||
2d_physics/layer_8="EnemyHitbox"
|
||||
2d_physics/layer_11="Climbable"
|
||||
|
||||
[mono]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=2]
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2]
|
||||
|
|
@ -28,6 +28,9 @@ extents = Vector2( 80, 2.5 )
|
|||
[sub_resource type="RectangleShape2D" id=5]
|
||||
extents = Vector2( 66.5, 80 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=6]
|
||||
extents = Vector2( 8, 55 )
|
||||
|
||||
[node name="Level" type="Node2D"]
|
||||
script = ExtResource( 10 )
|
||||
|
||||
|
|
@ -170,3 +173,12 @@ shape = SubResource( 5 )
|
|||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="Ladder" type="Area2D" parent="."]
|
||||
collision_layer = 1024
|
||||
collision_mask = 0
|
||||
|
||||
[node name="LadderShape" type="CollisionShape2D" parent="Ladder"]
|
||||
modulate = Color( 0.360784, 0.0901961, 0.0901961, 1 )
|
||||
position = Vector2( 441, 281 )
|
||||
shape = SubResource( 6 )
|
||||
|
|
|
|||
|
|
@ -74,3 +74,6 @@ func wants_dash() -> bool:
|
|||
|
||||
func wants_roll() -> bool:
|
||||
return false
|
||||
|
||||
func wants_climb() -> bool:
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=127 format=2]
|
||||
[gd_scene load_steps=128 format=2]
|
||||
|
||||
[ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/playerD/movement_component.gd" type="Script" id=2]
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
[ext_resource path="res://src/playerD/states/roll.gd" type="Script" id=14]
|
||||
[ext_resource path="res://src/playerD/states/die.gd" type="Script" id=15]
|
||||
[ext_resource path="res://src/templates/Interactable/Interactable_Receiver.gd" type="Script" id=16]
|
||||
[ext_resource path="res://src/playerD/states/climb.gd" type="Script" id=17]
|
||||
|
||||
[sub_resource type="StreamTexture" id=90]
|
||||
load_path = "res://.import/Mega.png-93dfe0790902b932f7b46f7b23c5d4e7.stex"
|
||||
|
|
@ -570,12 +571,14 @@ interactable_node = NodePath("../Interactable_Receiver")
|
|||
|
||||
[node name="idle" parent="movement_state_machine" index="0"]
|
||||
script = ExtResource( 4 )
|
||||
debug_state = true
|
||||
move_speed = 0.0
|
||||
animation_sequence = [ "idle" ]
|
||||
jump_node = NodePath("../jump")
|
||||
attack_node = NodePath("../attack")
|
||||
dash_node = NodePath("../dash")
|
||||
roll_node = NodePath("../roll")
|
||||
climb_node = NodePath("../climb")
|
||||
|
||||
[node name="fall" parent="movement_state_machine" index="1"]
|
||||
script = ExtResource( 6 )
|
||||
|
|
@ -642,6 +645,13 @@ idle_node = NodePath("../idle")
|
|||
script = ExtResource( 15 )
|
||||
animation_sequence = [ "die" ]
|
||||
|
||||
[node name="climb" type="Node" parent="movement_state_machine" index="9"]
|
||||
script = ExtResource( 17 )
|
||||
debug_state = true
|
||||
move_speed = 0.0
|
||||
animation_sequence = [ "climb" ]
|
||||
idle_node = NodePath("../idle")
|
||||
|
||||
[node name="Hurtbox_Component" parent="." index="4"]
|
||||
collision_layer = 16
|
||||
collision_mask = 128
|
||||
|
|
@ -677,6 +687,15 @@ interactable_parent_callback = "touch_the_thing"
|
|||
modifier_parent_callback = "receive_modifier"
|
||||
debug_receiver = true
|
||||
|
||||
[node name="Ladder_Detection" type="RayCast2D" parent="." index="10"]
|
||||
modulate = Color( 0.247059, 0.92549, 0.0313726, 1 )
|
||||
position = Vector2( 0, 5 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 0, 15 )
|
||||
collision_mask = 1024
|
||||
collide_with_areas = true
|
||||
collide_with_bodies = false
|
||||
|
||||
[connection signal="do_attack" from="movement_state_machine/attack" to="." method="_on_attack_do_attack"]
|
||||
[connection signal="frame_reached" from="movement_state_machine/roll" to="." method="_on_roll_frame_reached"]
|
||||
[connection signal="state_exited" from="movement_state_machine/roll" to="." method="_on_roll_state_exited"]
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export var player_number: int = 1
|
|||
export (NodePath) var interactable_node
|
||||
|
||||
onready var interactable_receiver_node: Interactable_Receiver = get_node(interactable_node)
|
||||
onready var ladder_detection:RayCast2D = $"../Ladder_Detection"
|
||||
|
||||
|
||||
func process_physics(delta):
|
||||
|
|
@ -70,6 +71,12 @@ func wants_roll() -> bool:
|
|||
else:
|
||||
return false
|
||||
|
||||
func wants_climb() -> bool:
|
||||
if ladder_detection.is_colliding() and Input.is_action_pressed("ui_up"):
|
||||
print("betcha wanna climb though!")
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
## Other needed variables
|
||||
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state
|
||||
|
|
|
|||
36
src/playerD/states/climb.gd
Normal file
36
src/playerD/states/climb.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
extends StateAnimatedActor
|
||||
|
||||
export (NodePath) var idle_node
|
||||
|
||||
onready var idle_state: StateAnimatedActor = get_node(idle_node)
|
||||
#onready var landing_mod: StateModifier = get_node(landing_node)
|
||||
|
||||
var climbing_modifier: StateModifier
|
||||
|
||||
func _ready():
|
||||
climbing_modifier= StateModifier.new()
|
||||
#add_child(modifier)
|
||||
#modifier.init_ref()
|
||||
climbing_modifier.ready( "landing", "jump" , climbing_modifier.TYPE.EXIT_ANIMATION)
|
||||
climbing_modifier.starting_frame = 6
|
||||
#print("ready! MOD")
|
||||
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
animations.frame = 5
|
||||
|
||||
func process_physics(delta: float) -> State:
|
||||
|
||||
# First allow horizontal movement.
|
||||
#move_actor_as_desired(delta)
|
||||
|
||||
#Flip the character before tha actual move maybe.
|
||||
if move_component.get_movement_direction() != 0.0:
|
||||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
# if parent.is_on_floor():
|
||||
# #modifier.reference()
|
||||
# idle_state.modifier = climbing_modifier
|
||||
# return idle_state
|
||||
return null
|
||||
|
|
@ -37,7 +37,6 @@ func process_physics(delta: float) -> State:
|
|||
parent.transform.x.x = move_component.get_movement_direction()
|
||||
|
||||
if parent.is_on_floor():
|
||||
print("DO you even!?: ", landing_modifier.animation_name)
|
||||
#modifier.reference()
|
||||
idle_state.modifier = landing_modifier
|
||||
return idle_state
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export (NodePath) var jump_node
|
|||
export (NodePath) var attack_node
|
||||
export (NodePath) var dash_node
|
||||
export (NodePath) var roll_node
|
||||
export (NodePath) var climb_node
|
||||
|
||||
onready var fall_state: State = get_node(fall_node)
|
||||
onready var move_state: State = get_node(move_node)
|
||||
|
|
@ -13,6 +14,7 @@ onready var jump_state: State = get_node(jump_node)
|
|||
onready var attack_state: State = get_node(attack_node)
|
||||
onready var dash_state: State = get_node(dash_node)
|
||||
onready var roll_state: State = get_node(roll_node)
|
||||
onready var climb_state: State = get_node(climb_node)
|
||||
|
||||
func enter() -> void:
|
||||
.enter()
|
||||
|
|
@ -34,6 +36,8 @@ func process_physics(delta: float) -> State:
|
|||
if move_component.wants_dash() and parent.is_on_floor():
|
||||
return dash_state
|
||||
|
||||
if move_component.wants_climb():
|
||||
return climb_state
|
||||
|
||||
if move_component.wants_shoot():
|
||||
return attack_state
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user