I have a separate script for player 1 and player 2, but they act like they are both interpreting the same controls from my one controller. When I take the P2 script off the second character, player 2 will not move. If I take the Player 1 script off of player 1, player 2 still moves.
Here is my Player 1 script:
// Determine the angle of the left thumbstick
var xAxis = Input.GetAxis("L_XAxis_1");
var yAxis = Input.GetAxis("L_YAxis_1");
//reset rotation so rigidbodies don't get flipped
transform.rotation = Quaternion.identity;
//find the target to move towards
var xtarget = transform.position.x + xAxis;
var ytarget = transform.position.y + yAxis;
var target = Vector3(xtarget, ytarget, 0);
// The step size is equal to speed times frame time.
//This finds how hard the player is pushing the joystick, and changes speed
speed = Vector2(xAxis, yAxis).magnitude * 4 ;
var step = speed * Time.deltaTime;
// Move our position a step closer to the target.
transform.position = Vector3.MoveTowards(transform.position, target, step);
And here is my Player 2 script:
// Determine the angle of the left thumbstick
var xAxis = Input.GetAxis("L_XAxis_2");
var yAxis = Input.GetAxis("L_YAxis_2");
//reset rotation so rigidbodies don't get flipped
transform.rotation = Quaternion.identity;
//find the target to move towards
var xtarget = transform.position.x + xAxis;
var ytarget = transform.position.y + yAxis;
var target = Vector3(xtarget, ytarget, 0);
// The step size is equal to speed times frame time.
//This finds how hard the player is pushing the joystick, and changes speed
speed = Vector2(xAxis, yAxis).magnitude * 4 ;
var step = speed * Time.deltaTime;
// Move our position a step closer to the target.
transform.position = Vector3.MoveTowards(transform.position, target, step);
Here is the input for movement (only showed left x axis, because it’s a big picture):
Here is the player 1 gameobject:
And here is the player 2 gameobject:
Do you see where the problem might be? My controller seems to work fine.