22 lines
513 B
GDScript3
22 lines
513 B
GDScript3
|
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
|
||
|
|
||
|
func getZoomLevel() -> float:
|
||
|
return currentZoom
|