mlpcardgame/Scenes/Scripts/Camera.gd
2019-05-04 21:34:03 +02:00

22 lines
No EOL
513 B
GDScript

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