Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!