summaryrefslogtreecommitdiffstats
path: root/game_camera.gd
blob: a92f23c1e97a6a34299af00dc55efcd58e8cfb03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extends Camera2D

## Amount to smoothly offset the camera if the parent is a Player.
@export var offset_amt: Vector2

func _ready() -> void:
	if not position_smoothing_enabled:
		await get_tree().create_timer(0.1).timeout
		position_smoothing_enabled = true

func _process(_delta: float) -> void:
	var parent = get_parent()
	if parent is Player:
		var player: Player = parent
		position.x = player.get_facing() * offset_amt.x

		if not player.is_on_floor():
			position.y = offset_amt.y
		else:
			position.y = 0