Compare commits
No commits in common. "346f87831bbad5b2bb41ff758eda1cfd09845abc" and "762b25c70b5c8b32d0138d0d5fddbd6b3142a1a6" have entirely different histories.
346f87831b
...
762b25c70b
1 changed files with 12 additions and 11 deletions
|
|
@ -41,11 +41,9 @@ const MIN_LAND_SPEED_FOR_SPLAT = 60.0
|
||||||
const LAND_PITCH_MIN = 0.87
|
const LAND_PITCH_MIN = 0.87
|
||||||
const LAND_PITCH_MAX = 1.15
|
const LAND_PITCH_MAX = 1.15
|
||||||
|
|
||||||
###############
|
# ---- State ----
|
||||||
## Variables ##
|
|
||||||
###############
|
|
||||||
var isStickingToWall := false
|
var isStickingToWall := false
|
||||||
var wallNormalX := 0.0
|
var wallNormalX := 0.0 # -1 if the wall faces left, 1 if it faces right.
|
||||||
var isStickingToCeiling := false
|
var isStickingToCeiling := false
|
||||||
|
|
||||||
var timeSpentUnstickingWall := 0.0
|
var timeSpentUnstickingWall := 0.0
|
||||||
|
|
@ -73,9 +71,9 @@ var wrapArcStartAngle := 0.0 # Angle around the corner where the arc begins.
|
||||||
var wrapSpeed := 0.0
|
var wrapSpeed := 0.0
|
||||||
var wrapDistanceTravelled := 0.0
|
var wrapDistanceTravelled := 0.0
|
||||||
|
|
||||||
###########
|
|
||||||
## Nodes ##
|
# ---- Nodes ----
|
||||||
###########
|
|
||||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
@onready var collisionShape: CollisionShape2D = $CollisionShape2D
|
@onready var collisionShape: CollisionShape2D = $CollisionShape2D
|
||||||
# Edge-finding raycasts, one each side, under a pivot we turn to face the surface we're on.
|
# Edge-finding raycasts, one each side, under a pivot we turn to face the surface we're on.
|
||||||
|
|
@ -112,7 +110,7 @@ func _physics_process(delta: float) -> void:
|
||||||
_update_wrap(delta)
|
_update_wrap(delta)
|
||||||
return
|
return
|
||||||
|
|
||||||
var wasInAir := (_get_surface_normal() == Vector2.ZERO)
|
var wasInAir := _get_surface_normal() == Vector2.ZERO
|
||||||
if not wasInAir:
|
if not wasInAir:
|
||||||
isHoppingAcross = false
|
isHoppingAcross = false
|
||||||
|
|
||||||
|
|
@ -130,7 +128,7 @@ func _physics_process(delta: float) -> void:
|
||||||
_update_horizontal_movement(delta, xInput, yInput)
|
_update_horizontal_movement(delta, xInput, yInput)
|
||||||
_hold_at_edge(delta)
|
_hold_at_edge(delta)
|
||||||
|
|
||||||
var wasOnWall := (isStickingToWall and not is_on_floor())
|
var wasOnWall := isStickingToWall and not is_on_floor()
|
||||||
var velocityBeforeMove := velocity
|
var velocityBeforeMove := velocity
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
@ -169,10 +167,13 @@ func _update_facing(xInput: float, yInput: float) -> void:
|
||||||
if isStickingToCeiling:
|
if isStickingToCeiling:
|
||||||
sprite.flip_h = xInput > 0 # Upside down, so flipped the other way.
|
sprite.flip_h = xInput > 0 # Upside down, so flipped the other way.
|
||||||
elif isStickingToWall:
|
elif isStickingToWall:
|
||||||
if wallNormalX < 0: sprite.flip_h = yInput < 0
|
if wallNormalX < 0:
|
||||||
else: sprite.flip_h = yInput > 0
|
sprite.flip_h = yInput < 0
|
||||||
|
else:
|
||||||
|
sprite.flip_h = yInput > 0
|
||||||
else:
|
else:
|
||||||
sprite.flip_h = xInput < 0
|
sprite.flip_h = xInput < 0
|
||||||
|
|
||||||
|
|
||||||
func _update_animation(xInput:float, yInput:float):
|
func _update_animation(xInput:float, yInput:float):
|
||||||
if xInput and (isStickingToCeiling or is_on_floor()):
|
if xInput and (isStickingToCeiling or is_on_floor()):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue