16 lines
550 B
GDScript
16 lines
550 B
GDScript
extends Camera2D
|
|
|
|
## Desired value of zoom
|
|
@export var normal_zoom: float = 0.4
|
|
## Value of hull's scalar_velocity where zoom will be equal to normal_zoom
|
|
@export var normal_zoom_velocity: float = 200.0
|
|
## Maximum value of zoom
|
|
@export var max_zoom: float = 0.5
|
|
## Shortcut to get_parent()
|
|
@onready var ship: PlayerShip = get_parent()
|
|
|
|
func _process(_delta):
|
|
var scalar_velocity = ship.hull.scalar_velocity
|
|
zoom = Vector2(1, 1) * normal_zoom * (normal_zoom_velocity / (scalar_velocity + 1))
|
|
if zoom.x > max_zoom:
|
|
zoom = Vector2(1, 1) * max_zoom
|