How to add momentum to camera movement

Viewed 58

I'm trying to make the camera follow the player movement

but the problem is when the condition that make the camera follow the player is not met it immediately stops which does not looks realistic

i want it to move a little further after the condition is evaluated to false

sorry that my English is not good but here's the code to clarify things up

void Update()
    {
        if(player.position.x - transform.position.x >= 3 && transform.position.x <= 1.35)
        {
            transform.Translate(3.5f * Time.deltaTime, 0, 0);
        }
        else if (player.position.x - transform.position.x <= -3  && transform.position.x >= -1.35)
        {
            transform.Translate(-3.5f * Time.deltaTime, 0, 0);
        }
        else
        {

        }
    }
0 Answers
Related