mlpcardgame/Scenes/Scripts/Camera.gd

22 lines
509 B
GDScript3
Raw Normal View History

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
func get_zoom() -> float:
2019-05-04 19:33:47 +00:00
return currentZoom