UNITY 2D WREGNY PATROL

public class PatrollingWallToWall : MonoBehaviour
{
    public float mMovementSpeed = 3.0f;
    public bool bIsGoingRight = true;

    private SpriteRenderer _mSpriteRenderer;

    // Start is called before the first frame update
    void Start()
    {
        _mSpriteRenderer = gameObject.GetComponent<SpriteRenderer>();
        _mSpriteRenderer.flipX = bIsGoingRight;
    }

    
    void Update()
    {
        // if the ennemy is going right, get the vector pointing to its right
        Vector3 directionTranslation = (bIsGoingRight) ? transform.right : -transform.right; 
        directionTranslation *= Time.deltaTime * mMovementSpeed;

        transform.Translate(directionTranslation);


        //CheckForWalls();
    }
}
Usama TKD