Better screen
This commit is contained in:
19
OffsetCameraBasedOnMovement.gd
Normal file
19
OffsetCameraBasedOnMovement.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Camera2D
|
||||
|
||||
@export var target: Vector2 = Vector2.ZERO
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
self.position = lerp(self.position, target, 0.8 * delta)
|
||||
|
||||
func set_target(facing: String):
|
||||
if facing == "E" or facing == "SE" or facing == "NE":
|
||||
target = Vector2(1600, 0)
|
||||
elif facing == "W" or facing == "SW" or facing == "NW":
|
||||
target = Vector2(-1600, 0)
|
||||
else:
|
||||
target=Vector2.ZERO
|
||||
Reference in New Issue
Block a user