- Home /
Controll 2 players with 2 different xbox controllers
Ok, so i can move my player with my xbox controller. But what if i want to controll 2 different players with 2 different xbox controllers on the the same computer?
Any help apreciated
Answer by programer717 · Jan 31, 2019 at 02:50 PM
Hi, I am no expert on this, but this may answer your question.
if not here is my suggestion, make two game objects that receive input from two different ports on the computer, then send messages (like UpButtonDown as a public bool and turning it on and of in the player script). Then you would just make two players and only access the script on the player you want to. like this.
Component Player1;
Component player2;
// Use this for initialization
void Start () {
player2 = gameObject.GetComponent<ScriptNameHere>();
Player1 = gameObject.GetComponent<ScriptNameHere>();
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Joystick1Button1))
{
Player1.BoolName = true;
}
else { Player1.BoolName = false; }
}
}
just pretend you have another script that has "BoolName", and whenever it is false the player the script is attached to moves forward.
Your answer
Follow this Question
Related Questions
Using an Xbox controller with GUI buttons 0 Answers
Xbox controller double input (right stick axis) 0 Answers
How do you properly deal with analog joystick input on multiple controller inputs? 1 Answer
How do I use an Input axis instead of Input.mousePosition??? 1 Answer
Accessing quadrant/joystick number when using multiple xbox 360 controllers 1 Answer