I have a script written for my camera to follow the player as it moves around, and it works on the X-axis, but not the Y, give me suggestions. I’m new to code.
Here is the code:
public class FollowPlayer : MonoBehaviour
{
//Variables
private Transform PlayerTransform;
public GameObject Player;
public Rigidbody2D rb;
void Start()
{
PlayerTransform = GameObject.FindGameObjectWithTag(“Player”).transform;
}
void LateUpdate()
{
Vector3 temp = transform.position;
temp.x = PlayerTransform.position.x;
transform.position = temp;
temp.y = PlayerTransform.position.y;
}
}