Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda