Best way to implement players instances and control input

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zeitgeist

So, I am trying to build a first project which is a top down shooter.
I wanted it to have a single or 2 player mode and to be able to be played on pc and with controlers (so I can learn all these aspects through the jorney).

In this way I thought in creating only 1 player scene, instantiate this scene either as a player, enemies or player 1 and player 2.

I then thought of having an input control scene responsible to gather the inputs for each player and then, depending on game mode and the players instantiates, attach the control scene to each one accordingly.

I thought this would be a way to garantee scalability and guarantee against changes on controls, number of players etc.

The problem I am facing is that some of the controls and functions like collide_info do not differentiate between instantiated “player” nodes, and treat player one, player two or enemies all as “player”. Also, this is getting me headaches to control the inputs and checks since everything depends on being instantiated and checked at the right time.

So what is the best way to design something like that either in terms of code or designing the node structure of the project?

Should I create a “player Scene” for each type of player? (player 1, player 2, enemies all have different “player scenes”?)
Is that a way to circunvate the problem of functions identifying the instaces as if they were the same?

Any documentation that could help here?

Thanks

:bust_in_silhouette: Reply From: PhantomPixel

So basically, you want multiplayer in Godot(at least I think that is what you want to do with 2 player mode). Here is some tutorials: