Revert "blah"
This reverts commit 454624856d1f686e4ce5e3df4e6a5e2b47cfc83d.
This commit is contained in:
parent
f70cc0b97a
commit
64188a72d3
3 changed files with 17 additions and 7 deletions
1
.vscode/settings.json
vendored
Executable file
1
.vscode/settings.json
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
const MOVE_SPEED = 150.0
|
||||
const GROUND_SPEED = 150.0
|
||||
const AIR_SPEED = 75.0
|
||||
|
||||
const CLIMB_SPEED = -150.0
|
||||
const JUMP_VELOCITY = -250.0
|
||||
|
||||
const ROTATE_TO_WALL_SPEED = 25 # How quickly to rotate the sprite when clinging to a wall.
|
||||
const CEILING_STICK_SPEED = -20.0 # Small upward push that keeps the slime pressed against the ceiling.
|
||||
|
|
@ -46,31 +47,36 @@ func _physics_process(delta: float) -> void:
|
|||
# If on ceiling, pressing down long enough unsticks from ceiling.
|
||||
if verticalInput < 0: timeSpentUnstickingCeiling += delta
|
||||
else: timeSpentUnstickingCeiling = 0.0
|
||||
|
||||
if timeSpentUnstickingCeiling >= MAX_SECS_TO_UNSTICK:
|
||||
isStickingToCeiling = false
|
||||
velocity.y = get_gravity().y * delta
|
||||
else: velocity.y = CEILING_STICK_SPEED
|
||||
|
||||
# Move up and down along a wall when sticking to it.
|
||||
elif isStickingToWall:
|
||||
velocity.y = CLIMB_SPEED * verticalInput
|
||||
elif not is_on_floor():
|
||||
velocity.y += get_gravity().y * delta
|
||||
|
||||
# Horizontal Input Controls
|
||||
# If sticking to a wall, pressing away from it long enough gets us unstuck.
|
||||
if isStickingToWall and not is_on_floor():
|
||||
var pressingAwayFromWall := horizontalInput * wallNormalX > 0
|
||||
if pressingAwayFromWall: timeSpentUnstickingWall += delta
|
||||
else: timeSpentUnstickingWall = 0.0
|
||||
|
||||
if timeSpentUnstickingWall >= MAX_SECS_TO_UNSTICK:
|
||||
velocity.x = horizontalInput * MOVE_SPEED
|
||||
velocity.x = horizontalInput * GROUND_SPEED
|
||||
else:
|
||||
velocity.x = -wallNormalX * WALL_STICK_SPEED
|
||||
# Otherwise move horizontally based on what we're on.
|
||||
else:
|
||||
timeSpentUnstickingWall = 0.0
|
||||
if horizontalInput: velocity.x = horizontalInput * MOVE_SPEED
|
||||
else: velocity.x = move_toward(velocity.x, 0, MOVE_SPEED)
|
||||
if horizontalInput and (is_on_floor() or isStickingToCeiling):
|
||||
velocity.x = horizontalInput * GROUND_SPEED
|
||||
elif horizontalInput and not (is_on_floor() or isStickingToCeiling):
|
||||
velocity.x = horizontalInput * AIR_SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, GROUND_SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
|
@ -78,6 +84,8 @@ func _physics_process(delta: float) -> void:
|
|||
isStickingToWall = is_on_wall()
|
||||
if isStickingToWall:
|
||||
wallNormalX = get_wall_normal().x
|
||||
|
||||
# Check if we are attempting to climb a lip.
|
||||
isStickingToCeiling = is_on_ceiling()
|
||||
|
||||
# In a corner touching both wall and ceiling, only stick to one
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ pause={
|
|||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
2d/default_gravity=700.0
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue