Need help switching between to active objects!

Hey forums, first time post and a newbie.
I have two spherical objects that are both coded similarly to be able to move throughout the gamespace. I want to be able to hit a key and switch between the two objects, as each object has different purposes in the game. Basically the problem im running into is that I can switch between the objects and make one or the other invisible, however as I continue to hit the arrow keys even the invisible object is still moving throughout the gamespace.

Just have a variable, perhaps called “isCurrent” and a bool, that the script has. When you switch between objects, make the new active one have isCurrent true, and the now inactive one have isCurrent false. Use an if() statement checking that isCurrent is true, before doing any movement key checks.

The problem with this approach is that if later in your development you decide you want 100 of these spherical objects, then you have 100 game objects that all have the same script on them, and all of them are checking for key presses. That’s a bit clunky. So, once you’ve got the suggestion above working, and you’re happy with it, then think about this more complex approach. Create a movement management script. It’s checking for key presses, and maintains a list of your spherical object. When the spherical objects get created have their Start() function send a message to your management script to say “hey, I’m alive and want to be controlled by you”. Your movement script will then add this new object onto it’s list. The management script will have a single variable that it uses to store the currently active sphere. All movement will be routed to that active sphere. The key that says move to a different sphere will just change the sphere that’s stored in the single active variable. I’ve not tried to spell this out in any detail, just giving you some advice you might come back to in a few weeks.