Functional launch mechanic in up and down vector
This commit is contained in:
@ -168,7 +168,7 @@ func _update_state(
|
|||||||
# Continue climbing logic (finding next grip) happens in _process_climbing
|
# Continue climbing logic (finding next grip) happens in _process_climbing
|
||||||
MovementState.CHARGING_LAUNCH:
|
MovementState.CHARGING_LAUNCH:
|
||||||
if not (reach_input.pressed or reach_input.held):
|
if not (reach_input.pressed or reach_input.held):
|
||||||
_execute_launch()
|
_execute_launch(move_input)
|
||||||
elif move_input == Vector2.ZERO: # Cancel charge while holding interact
|
elif move_input == Vector2.ZERO: # Cancel charge while holding interact
|
||||||
current_state = MovementState.GRIPPING
|
current_state = MovementState.GRIPPING
|
||||||
print("ZeroGMovementComponent: Cancelled Launch Charge")
|
print("ZeroGMovementComponent: Cancelled Launch Charge")
|
||||||
@ -368,20 +368,18 @@ func _get_hold_distance() -> float:
|
|||||||
return 0.5 # Fallback distance if detector isn't set up right
|
return 0.5 # Fallback distance if detector isn't set up right
|
||||||
|
|
||||||
func _release_current_grip(move_input: Vector2 = Vector2.ZERO):
|
func _release_current_grip(move_input: Vector2 = Vector2.ZERO):
|
||||||
var was_climbing = (current_state == MovementState.CLIMBING)
|
|
||||||
|
|
||||||
if is_instance_valid(current_grip):
|
if is_instance_valid(current_grip):
|
||||||
current_grip.release(pawn)
|
current_grip.release(pawn)
|
||||||
current_grip = null
|
current_grip = null
|
||||||
|
|
||||||
# If we were climbing and are still holding a climb input, start seeking.
|
# If we were climbing and are still holding a climb input, start seeking.
|
||||||
if was_climbing and move_input != Vector2.ZERO:
|
if move_input != Vector2.ZERO:
|
||||||
current_state = MovementState.SEEKING_CLIMB
|
current_state = MovementState.SEEKING_CLIMB
|
||||||
_seeking_climb_input = move_input # Store the input that started the seek
|
_seeking_climb_input = move_input # Store the input that started the seek
|
||||||
print("ZeroGMovementComponent: Released grip, now SEEKING_CLIMB.")
|
# print("ZeroGMovementComponent: Released grip, now SEEKING_CLIMB.")
|
||||||
else:
|
else:
|
||||||
current_state = MovementState.IDLE
|
current_state = MovementState.IDLE
|
||||||
print("ZeroGMovementComponent: Released grip, now IDLE.")
|
# print("ZeroGMovementComponent: Released grip, now IDLE.")
|
||||||
|
|
||||||
|
|
||||||
func _cancel_reach():
|
func _cancel_reach():
|
||||||
@ -401,7 +399,7 @@ func _start_climb(move_input: Vector2):
|
|||||||
print("ZeroGMoveController: Started Climbing in direction: ", (pawn_up * move_input.y + pawn_right * move_input.x).normalized())
|
print("ZeroGMoveController: Started Climbing in direction: ", (pawn_up * move_input.y + pawn_right * move_input.x).normalized())
|
||||||
|
|
||||||
func _stop_climb(release_grip: bool):
|
func _stop_climb(release_grip: bool):
|
||||||
print("ZeroGMoveController: Stopping Climb. Release Grip: ", release_grip)
|
# print("ZeroGMoveController: Stopping Climb. Release Grip: ", release_grip)
|
||||||
pawn.velocity = pawn.velocity.lerp(Vector3.ZERO, 0.5) # Apply some braking
|
pawn.velocity = pawn.velocity.lerp(Vector3.ZERO, 0.5) # Apply some braking
|
||||||
next_grip_target = null
|
next_grip_target = null
|
||||||
if release_grip:
|
if release_grip:
|
||||||
@ -444,16 +442,16 @@ func _handle_launch_charge(delta: float):
|
|||||||
# _movement_input_was_neutral = false # Ensure we don't immediately thrust after launch
|
# _movement_input_was_neutral = false # Ensure we don't immediately thrust after launch
|
||||||
|
|
||||||
|
|
||||||
func _execute_launch():
|
func _execute_launch(move_input: Vector2):
|
||||||
if not is_instance_valid(current_grip): return # Safety check
|
if not is_instance_valid(current_grip): return # Safety check
|
||||||
_release_current_grip() # Release AFTER calculating direction
|
|
||||||
pawn.velocity = launch_direction * launch_charge # Apply launch velocity to pawn
|
pawn.velocity = launch_direction * launch_charge # Apply launch velocity to pawn
|
||||||
launch_charge = 0.0
|
launch_charge = 0.0
|
||||||
|
_release_current_grip(move_input) # Release AFTER calculating direction
|
||||||
|
|
||||||
# Instead of going to IDLE, go to SEEKING_CLIMB to find the next grip.
|
# Instead of going to IDLE, go to SEEKING_CLIMB to find the next grip.
|
||||||
# The move_input that started the launch is what we'll use for the seek direction.
|
# The move_input that started the launch is what we'll use for the seek direction.
|
||||||
_seeking_climb_input = (pawn.global_basis.y.dot(launch_direction) * Vector2.UP) + (pawn.global_basis.x.dot(launch_direction) * Vector2.RIGHT)
|
# _seeking_climb_input = (pawn.global_basis.y.dot(launch_direction) * Vector2.UP) + (pawn.global_basis.x.dot(launch_direction) * Vector2.RIGHT)
|
||||||
current_state = MovementState.SEEKING_CLIMB
|
# current_state = MovementState.SEEKING_CLIMB
|
||||||
print("ZeroGMovementComponent: Launched with speed ", pawn.velocity.length(), " and now SEEKING_CLIMB")
|
print("ZeroGMovementComponent: Launched with speed ", pawn.velocity.length(), " and now SEEKING_CLIMB")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user