extends Camera3D
class_name CameraManager

var target:int
var offset:Vector3

func _ready():
	Global.camera_mgr = self
	SignalManager.character_create.connect(on_character_create)
	SignalManager.character_pos_changed.connect(on_character_pos_changed)
	SignalManager.character_destroy.connect(on_character_destroy)
	
func _process(delta):
	pass
	
func on_character_create(id:int,team:Enum.ETeam,pos:Vector3):
	if team == Enum.ETeam.Player:
		target = id
		offset = position - pos
	
func on_character_pos_changed(id:int,pos:Vector3):
	if id == target:
		position = pos + offset

func on_character_destroy(id:int):
	target = 0
	offset = Vector3.ZERO
