I am creating a platform 2d game, this game has two main characters (playable), I want to switch the character during the game.

example: one of the characters can not spend a obstacle, the other can, then I switch the character to be able to pass this obstacle. thank you

Run the Movement code in a separate script REFERENCING the current Player. Swap him out on the button press for changing the player.

sorry, I’m new to unity, I could make an example script