- Home /
how to use LeanTween to tween camera orthographicSize
I need to tween the orthographic size of my camera but I`enter code here` don't really know how to use LeanTween that well... using System.Collections; using System.Collections.Generic; using UnityEngine;
public class HexZoom : MonoBehaviour {
public Camera camera;
private float zoom;
public void zoomIn(){
camera.orthographicSize = LeanTween.value(camera.gameObject, camera.orthographicSize, 0.5f, 1.7f);
}
public void zoomOut()
{
}
}
Answer by brendanperry05 · Aug 07, 2018 at 07:38 PM
I struggled with using LeanTween.value initially as well. Here is what I found to make it work:
public void zoomIn(){
LeanTween.value(camera.gameObject, camera.orthographicSize, 0.5f, 1.7f).setOnUpdate((float flt) => {
camera.orthographicSize = flt;
});
}
float flt is increased / decreased over time and then your camera size is set to it
You can find more information on their documentation page.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
iTween's inaccuracy of final position 2 Answers
How do I make the camera stay on a fixed Z-pos where it moves X/Y delayed from the player object? 0 Answers
How do I get my camera to rotate around the y=0 coordinate it's looking at? 0 Answers
How do I render a scene's depth buffer when I have custom vertex shaders? 0 Answers