I’m trying to focus camera on enemy sprite once it hits the ground, however using Vector3.Lerp gives me headaches because it doesn’t work as I expected.
if(collision.gameObject.CompareTag("EndGround"))
{
GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation;
GetComponent<Rigidbody2D>().angularDrag = 1000;
ChangeCamera = true;
}
void FixedUpdate () {
if(ChangeCamera)
{
GameObject.Find("Main Camera").GetComponent<CameraFollow>().enabled = false;
PlayerCamera.transform.position = Vector3.Lerp(player.transform.position, transform.position - offset, Time.deltaTime * 3f);
}
}
Script is attached to enemy and when he hits the ground the bool sets to true in FixedUpdate. First I disable camera follow script so it’s not following my player anymore, then it should move the the current position of player. If I set the time in Lerp to 1 or more it goes there immedietly, but if it’s less than one then it doesn’t even reach the target. If it’s 0.5 then it goes halfway there. I guess I don’t understnad Lerp.