0
\$\begingroup\$

I'm using this script to follow a game object in 2D :

public class CameraFollow : MonoBehaviour
{
    ...
    void LateUpdate(){
        Vector3 position = target_transform.position;
        float targetX = position.x;
        float targetY = position.y;
        targetX = Mathf.Lerp(transform.position.x, targetX, 1/m_DampTime * Time.deltaTime);
        targetY = Mathf.Lerp(transform.position.y, targetY, m_DampTime * Time.deltaTime);
        transform.position = new Vector3(targetX, targetY, initial_z);
    }
}

I've set damping time to 2.

But with this when the object's speed gets higher it can't follow anymore, it lags. Any suggestions or solutions ?

Here is the current situation :

\$\endgroup\$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.