Good way to limit the character?

I’m having trouble to limit my character. It’d be easy if the way was straight, but the way have some turnings, then the character change the X axys position. Is there some way to limit the character if it change the X position?

Going to need some more detail here. What do you mean by “limit the character”?

limit the character movimentation

What, like stopping it from going past a certain point?

For that you could just use colliders.

Or if you really want to do it via code

if(transform.position.x >= desiredXBoundy)
    canMove = false;


else
    canMove = true