[SOLVED] 2 Player controls?

I’m a student doing a small school project game.
I have very little experience in scripting, so I’m using tutorial scripts for pretty much everything.

I’ve used the 2d platform controller to setup 2 characters in my game. I’ve made alternate inputs for moving and jumping, but how do I connect these in the script? Right now I move both characters simultaneously.

If you’ve already used the Input manager to set up new input axes, you will note that the new axes have different names. The built-in left-right axis is called “Horizontal” - for the second player, it might be called “Horizontal2”, say.

In your code, you just need to look for the Input.GetAxis calls and replace the existing axis name with the new one for the second player. So, if your player 1 script has something like:-

var x = Input.GetAxis("Horizontal");

…then your player 2 script might have:-

var x = Input.GetAxis("Horizontal2");
2 Likes

Well thank you andeeee.

I guess it was too obvious for me to see.

@andeeeee Do we make separate scripts? I’m using 3d ThirdPersonController,
so would I duplicate the script and change that?

No, just a case of creating an integer for playnumber, and then change the inputs to the playernumber accordingly.