mlpcardgame/Scenes/Scripts/Camera.gd

22 lines
No EOL
509 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 get_zoom() -> float:
return currentZoom