I want to smoothly translate the position of the camera to the position of the second player but Vector3.Lerp isn't working. I also want the size of the camera to smoothly go from 10 to 5 but Mathf.Lerp isn't working. Finally, I want the scale of the second player to go from 0.1 to 0.2.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Win: MonoBehaviour
{
public GameObject secondPlayer;
public GameObject firstPlayer;
public Camera cam;
private void OnCollisionEnter2D(Collision2D collision)
{
Vector2 scale = new Vector2(0.2f, 0.2f);
Vector3 positionOfSecondPlayer = new Vector3(secondPlayer.transform.position.x, secondPlayer.transform.position.y, -10);
if (collision.gameObject.layer == 3)
{
cam.orthographicSize = Mathf.Lerp(cam.orthographicSize, 5, 45);
cam.transform.position = Vector3.Lerp(secondPlayer.transform.position, positionOfSecondPlayer, 45);
Destroy(firstPlayer);
secondPlayer.transform.localScale = Vector2.Lerp(secondPlayer.transform.localScale, scale, 45);
}
}
}