As the title says I am trying to make the camera follow the player in a 2D platformer I am making, however it comes up with errors in this script, if any of you guys could help, I’m sorta new to Unity and c#. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollower : MonoBehaviour
{
private Transform myTransform;
public Transform PlayerTransform;
private void Awake ()
{
myTransform = GetComponent<Transform> ();
}
void LateUpdate ()
{
if (PlayerTransform.position.x <= .685449) {
myTransform.position.x = 0.685449;
}
else if (PlayerTransform.position.x >= 9.31455)
{
myTransform.position.x = 9.31455;
}
else
{
myTransform.position.x = PlayerTransform.position.x;
}
}
}