Compare commits
2 Commits
49e2030c06
...
5196b3eb6e
| Author | SHA1 | Date | |
|---|---|---|---|
| 5196b3eb6e | |||
| d3775c364f |
|
|
@ -30,6 +30,7 @@ var velocity_controller :VelocityController = VelocityController.new()
|
||||||
#var sim_velocity = Vector2(0,0)
|
#var sim_velocity = Vector2(0,0)
|
||||||
var physics_delta:float
|
var physics_delta:float
|
||||||
var process_delta:float
|
var process_delta:float
|
||||||
|
var state_duration:float = 0.0 ## Tracks how long we've been in state
|
||||||
|
|
||||||
var modifier: StateModifierMovement
|
var modifier: StateModifierMovement
|
||||||
|
|
||||||
|
|
@ -133,6 +134,8 @@ func get_climb_shape_location() -> Vector2:
|
||||||
return Vector2(-1,-1)
|
return Vector2(-1,-1)
|
||||||
|
|
||||||
func _on_state_change(old_state_name:String, new_state :State):
|
func _on_state_change(old_state_name:String, new_state :State):
|
||||||
|
## Reset State Duration Counter
|
||||||
|
state_duration = 0.0
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
## Confirmed that I do neet to update the current_state with the passed state.
|
## Confirmed that I do neet to update the current_state with the passed state.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ var player_number: int = 1
|
||||||
|
|
||||||
onready var pew_machine = $"%PewMachine"
|
onready var pew_machine = $"%PewMachine"
|
||||||
onready var stamina_component = $"%Stamina_Component"
|
onready var stamina_component = $"%Stamina_Component"
|
||||||
|
onready var ladder_detector = $"%LadderDetector"
|
||||||
|
|
||||||
|
|
||||||
var state_stamina_cost :Dictionary
|
var state_stamina_cost :Dictionary
|
||||||
|
|
||||||
|
|
@ -58,8 +60,10 @@ var _wants_crouch :bool
|
||||||
func wants_crouch() -> bool:
|
func wants_crouch() -> bool:
|
||||||
if Input.is_action_pressed("crouch_" + str(player_number)):
|
if Input.is_action_pressed("crouch_" + str(player_number)):
|
||||||
_wants_crouch = true
|
_wants_crouch = true
|
||||||
|
ladder_detector.position.y = 2
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
|
ladder_detector.position.y = 0
|
||||||
_wants_crouch = false
|
_wants_crouch = false
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
@ -333,6 +337,11 @@ func _state_process_physics_fall():
|
||||||
var foo = $"%LedgeDetector".is_colliding()
|
var foo = $"%LedgeDetector".is_colliding()
|
||||||
var bar = $"%WallDetector".is_colliding()
|
var bar = $"%WallDetector".is_colliding()
|
||||||
|
|
||||||
|
#parent.get_node("CollisionShape2D").set_deferred("disabled", false)
|
||||||
|
state_duration += physics_delta
|
||||||
|
if (state_duration > .25):
|
||||||
|
parent.set_collision_mask_bit(9,true)
|
||||||
|
|
||||||
if $"%LedgeDetector".is_colliding() and !$"%WallDetector".is_colliding():
|
if $"%LedgeDetector".is_colliding() and !$"%WallDetector".is_colliding():
|
||||||
#print("it touched me!")
|
#print("it touched me!")
|
||||||
if debug_component:
|
if debug_component:
|
||||||
|
|
@ -442,8 +451,6 @@ func get_climb_shape_location() -> Vector2:
|
||||||
|
|
||||||
|
|
||||||
func _state_process_physics_climb():
|
func _state_process_physics_climb():
|
||||||
#$"../LadderDetector".set_enabled(false)
|
|
||||||
|
|
||||||
var ladder_location = get_climb_shape_location()
|
var ladder_location = get_climb_shape_location()
|
||||||
if ladder_location != Vector2(-1,-1):
|
if ladder_location != Vector2(-1,-1):
|
||||||
#UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location))
|
#UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location))
|
||||||
|
|
@ -463,7 +470,7 @@ func _state_process_physics_climb():
|
||||||
return request_state_change.call_func('idle')
|
return request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
|
||||||
if _wants_crouch:
|
if _wants_jump:
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -525,6 +532,12 @@ func _state_process_physics_crouch():
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('idle')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if _wants_jump == true:
|
||||||
|
##TODO: Done to drop through one-way floors
|
||||||
|
#parent.get_node("CollisionShape2D").set_deferred("disabled", true)
|
||||||
|
parent.set_collision_mask_bit(9,false)
|
||||||
|
return
|
||||||
|
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
return
|
return
|
||||||
|
|
@ -536,6 +549,10 @@ func _state_process_physics_crouch():
|
||||||
request_state_change.call_func('move')
|
request_state_change.call_func('move')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if $"%LadderDetector".is_colliding():
|
||||||
|
request_state_change.call_func('climb')
|
||||||
|
return
|
||||||
|
|
||||||
apply_movement_to_parent(
|
apply_movement_to_parent(
|
||||||
velocity_controller.calculate_velocity(
|
velocity_controller.calculate_velocity(
|
||||||
physics_delta ,
|
physics_delta ,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ min_acceleration = Vector2( 0, 0 )
|
||||||
acceleration = Vector2( 0, 280 )
|
acceleration = Vector2( 0, 280 )
|
||||||
max_acceleration = Vector2( 0, 0 )
|
max_acceleration = Vector2( 0, 0 )
|
||||||
jerk_factor = Vector2( 1, 1 )
|
jerk_factor = Vector2( 1, 1 )
|
||||||
horizontal_speed = 20.0
|
horizontal_speed = 50.0
|
||||||
horizontal_acceleration = 0.0
|
horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
extents = Vector2( 8, 48 )
|
extents = Vector2( 8, 40 )
|
||||||
|
|
||||||
[node name="TC_05" groups=["world"] instance=ExtResource( 1 )]
|
[node name="TC_05" groups=["world"] instance=ExtResource( 1 )]
|
||||||
|
|
||||||
|
|
@ -92,9 +92,9 @@ collision_layer = 1024
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ladders" index="0"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ladders" index="0"]
|
||||||
position = Vector2( 136, 96 )
|
position = Vector2( 136, 88 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Ladders" index="1"]
|
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Ladders" index="1"]
|
||||||
position = Vector2( 200, 96 )
|
position = Vector2( 200, 88 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user