diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100755 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/Characters/player.gd b/Characters/player.gd index a05d95b..5fe095e 100755 --- a/Characters/player.gd +++ b/Characters/player.gd @@ -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 diff --git a/project.godot b/project.godot index fb27e04..7cef94f 100755 --- a/project.godot +++ b/project.godot @@ -70,6 +70,7 @@ pause={ [physics] 3d/physics_engine="Jolt Physics" +2d/default_gravity=700.0 [rendering]