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

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

# Called every frame. 'delta' is the elapsed time since the previous frame.
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