Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Achieve ease in ease out in Vector3 Lerp

I am moving my camera from origin to destination, it all works well but the problem is that there is no smooth ease in/out from origin to destination. How do I achieve a smooth ease in when camera is travelling and smooth ease out when the camera reaches the destination? It is necessary to have totalMovementTime as I want my camera to reach the destination in given seconds.

public IEnumerator MoveToDestination () {

        float totalMovementTime = 2f; 
        float currentMovementTime = 0f;
        while (Vector3.Distance (transform.localPosition, destinationCamPos) > 0) {
            currentMovementTime += Time.deltaTime;
            transform.localPosition = Vector3.Lerp (transform.localPosition, destinationCamPos, currentMovementTime / totalMovementTime);
            yield return null;
        }
    }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use the AnimationCurve for "easy" easing :) Create a serialized field in your script of type AnimationCurve. In inspector play with it making the desired easing curve (there are also ready to use presets). Then for the step (progress) of your lerp you need to "evaluate" using your curve AnimationCurve.Evaluate Make sure your are using the normalized value for the Lerp progress.

[SerializedField] AnimationCurve curve;
...
var normalizedProgress = currentMovementTime / totalMovementTime ; // 0-1
var easing = curve.Evaluate(normalizedProgress);
transform.localPosition = Vector3.Lerp (transform.localPosition, destinationCamPos, easing);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda