2019-05-04 19:33:47 +00:00
|
|
|
extends Camera
|
|
|
|
|
|
|
|
export var scaleFactor := 0.2
|
|
|
|
export var animSpeed := 20
|
|
|
|
|
|
|
|
var targetZoom := 0.0
|
|
|
|
var currentZoom := 0.0
|
|
|
|
|
|
|
|
func zoom(inward: bool):
|
|
|
|
var direction := 1
|
|
|
|
if !inward:
|
|
|
|
direction *= -1
|
|
|
|
targetZoom += scaleFactor * direction
|
|
|
|
|
|
|
|
func _process(delta: float):
|
|
|
|
if abs(targetZoom - currentZoom) > 0:
|
|
|
|
var deltaZoom := (targetZoom - currentZoom) * (delta * animSpeed)
|
|
|
|
transform = transform.translated(Vector3.FORWARD * deltaZoom)
|
|
|
|
currentZoom += deltaZoom
|
|
|
|
|
2019-05-05 22:39:55 +00:00
|
|
|
func get_zoom() -> float:
|
2019-05-04 19:33:47 +00:00
|
|
|
return currentZoom
|