Cheers, I do what I can =)
I would’ve thought using an if-statement is exactly how that issue gets solved in the first place: “if this player has authority, spawn the camera [else do nothing].” Unless I’m misunderstanding what you’re asking, you can definitely use add_child() in an if-statement. From the course, it would look something like this (can’t check for the exact syntax at the moment):
#pseudocode
for p in players:
if [p is local player]:
p.add_child(camera_instance)
break
It looks like you’re doing this in the game script (and not the player script itself), so you’ll need to call player.add_child() and not just add_child(). This is how the engine knows what to add it as a child of. add_child() belongs to the Node class (as in the white Node that everything inherits from), so everything when you call the function as a member of player, it’s a lot like navigating to a particular folder instead of dumping something straight onto the desktop (like I’m frequently guilty of).
I could see that being done in two different ways: you can have multiple cameras per player and set which one will be active (this is probably the cleaner way to do it); or you could reparent() the existing camera to some sort of invisible anchor above the player, as if they’re holding a bindle. reparent() does exactly the same thing as add_child(), but for something that already exists in the SceneTree.
If the camera is a child of the player, it will move with the player automatically because its Transform will be relative to the player’s Transform. Because this happens automatically, if you currently have code that makes the camera follow the player in some way, you probably need to disable it.
The way to make this not happen is to make the camera Top Level in its Inspector, which causes its Transform to behave independently despite the camera’s place in the SceneTree.
I’m sort of just info-dumping whatever relevant stuff comes to mind in the hopes that something triggers the a-ha moment you’re looking for =)