summaryrefslogtreecommitdiffstats
path: root/game_camera.gd
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-12-02 14:01:19 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-12-02 14:01:19 +0200
commit0b302feb975e74dba978b46562f3f3019d1cd2b9 (patch)
treed544672a9720dddce6e8399ade5b896b7d4d5dcc /game_camera.gd
parentc00d24f219ee7a7e2f2264a3add0baa2c34e600d (diff)
Add terrain
Diffstat (limited to 'game_camera.gd')
-rw-r--r--game_camera.gd17
1 files changed, 1 insertions, 16 deletions
diff --git a/game_camera.gd b/game_camera.gd
index 9545edd..5bcbacf 100644
--- a/game_camera.gd
+++ b/game_camera.gd
@@ -1,8 +1,5 @@
extends Camera2D
-## Amount to smoothly offset the camera if the parent is a Player.
-@export var offset_amt: Vector2
-
@onready var tree: SceneTree = get_tree()
func _ready() -> void:
@@ -18,19 +15,7 @@ func _process(_delta: float) -> void:
if targets.size() == 0: return
for target in targets:
- if target is Player:
- var player: Player = target
- var oy: float = 0
- if not player.is_on_floor():
- oy = offset_amt.y
- pos += Vector2(player.global_position.x + player.get_facing() * offset_amt.x,
- player.global_position.y + oy)
- elif target is Node2D:
- var node2d: Node2D = target
- pos += node2d.global_position
- else:
- assert(false, "camera_target node is invalid")
-
+ pos += target._camera_target()
n += 1
global_position = pos / n