I’m trying to make the Main Camera follow an object in unity 2d if its x position is greater than zero, but if the object was at less than zero and moves back past zero, the camera doesn’t follow it. Here’s the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CopyPosition: MonoBehaviour
{
[SerializeField]
Transform TransformTarget;
void Update()
{
if (transform.position.x >= 0)
{
transform.position = TransformTarget.position;
}
}
}