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

194
Visualizações
Smooth camera movement in Unity 2d

I am working on a 2d RPG game in unity and I wanted to add a smooth camera movement like Brackeys did in this video.

I already tried to use FixedUpdate(), Update() and LateUpdate(), but nothing when I hit play the camera is like lagging behind the player. The strange thing is that when I turn off the camera script the player moves fluidly.

I even tried Vector3.SmoothDamp() and Vector3.Lerp() but nothing it's still a bit laggy.

How do i solve it??

My code by far:

public class CameraMovement : MonoBehaviour

{

public Transform target;
public float smoothing;

void FixedUpdate()
{
    if(transform.position != target.position)
    {
        Vector3 targetPosition = new Vector3
        (target.position.x, target.position.y, 
        transform.position.z); 

        transform.position = Vector3.Lerp
        (transform.position, 
        targetPosition, smoothing);
    }
}

}

Target is the Player Transform.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try Removing this - if(transform.position != target.position) Statement.

And also multiply smoothing with time.deltatime. Here-

public Transform target;
public float smoothing;

    void FixedUpdate()
    {
    Vector3 targetPosition = new Vector3
    (target.position.x, target.position.y, 
    transform.position.z); 

    transform.position = Vector3.Lerp
    (transform.position, 
    targetPosition, smoothing*Time.deltatime);
    }
}
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