How to separate the player controls in a local multiplayer game at the same keybord
Hi Unity 3D community! I'm making a game with 3 characters for 3 players play at the same keyboard and everything is alright,except the fact that when I put my 3 characters at the game and press the walk button of one character, all the three walk too. I already tried to go to Edit /Project Settings /Input and create two more 'Horizontal' and put other commands to walk and jump, but happens the same thing.what can I do to solve this problem?
(sorry If the text has english issues, I'm brasilian)
Have you tried rena$$anonymous$$g the other keys something other than 'Horizontal' like 'Horizontal2' etc?
Correct as per the @$$anonymous$$aximumTre but additionally you need to remove the alternate registered keys from already defined Axis ( like from vertical : 'Alt Negative button s', Alt Positive button w' need to be remove )
Sorry for bad English
i tried what you had said but the keys of "Horizontal2" and "Horizontal3" don't work and when I press the keys of "Horizontal" the three walk together. Help me please
Answer by itsharshdeep · Feb 13, 2016 at 06:36 PM
Check the following detail :
using UnityEngine;
using System.Collections;
using System.IO;
public class Delete : MonoBehaviour
{
public enum Player {
Player1,
Player2,
Player3,
}
public Player choosePlayr;
Vector3 direction;
void Update() {
switch (choosePlayr)
{
case Player.Player1:
direction.x = Input.GetAxis("Horizontal");
direction.z = Input.GetAxis("Vertical");
break;
case Player.Player2:
direction.x = Input.GetAxis("Horizontal2");
direction.z = Input.GetAxis("Vertical2");
break;
case Player.Player3:
direction.x = Input.GetAxis("Horizontal3");
direction.z = Input.GetAxis("Vertical3");
break;
}
Move();
}
void Move() {
transform.Translate(direction.x, 0, direction.z);
}
}
You need to the do the following setting to make the script work:


Sorry 3rd image can't be attached here is following is the link to that image https://www.dropbox.com/s/ka3p72anf2eb7mi/Horizontal3.PNG?dl=0
Hope now you understand ( & I answered well ;) )
i tried what you had said but the keys of "Horizontal2" and "Horizontal3" don't work and when I press the keys of "Horizontal" the three walk together. Help me please
Your answer