Pls help i'm new

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;
        }
    }
}

The if statement should be checking TransformTarget’s position, not its own position.

2 Likes

It worked! Thanks, dude!

2 Likes