18 lines
		
	
	
		
			476 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			476 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
extends Camera2D
 | 
						|
@onready var global = $"/root/Player"
 | 
						|
var targetPosition = Vector2(0,0)
 | 
						|
var moving = true
 | 
						|
# Called when the node enters the scene tree for the first time.
 | 
						|
func _ready() -> void:
 | 
						|
	pass
 | 
						|
	global.connect("playerPosition",setTargetPosition)
 | 
						|
 | 
						|
 | 
						|
# Called every frame. 'delta' is the elapsed time since the previous frame.
 | 
						|
func _process(delta: float) -> void:
 | 
						|
	if moving == true:
 | 
						|
		self.set_position(targetPosition)
 | 
						|
 | 
						|
func setTargetPosition(pos):
 | 
						|
	targetPosition = pos
 |