Input Axis is not setup.... But works anyway?

So! I am getting that “Input Axis is not setup” error, for reasons I more or less understand, with my code doing exactly what I want it to. I just want to make it go away so when I have real errors during runtime, null reference etc i will be able to pick it up.

So here’s what I am doing.

I’ve made two variables:

private string leftStickX;
private string leftStickY;

I set these variables to be the axis name depending on if the player is player one or not.

// Define the axis controls
	leftStickX = "LXP1";
	leftStickY = "LYP1";

I use “LXP2” and “LYP2” for the other player.
So when I go to code I use:


Instead of


I figured it would work, and it does, because Unity just needs a string and I provided one
But I keep getting that Input axis error unless I use the one that says “LXP1”

So what do I do to get rid of it? I tried using .ToSting() just to make sure that unity understood that it’s a string. I knew that would be silly but i thought i’d give it a go anyway. it doesn’t get rid of the message anyway.

I am all out of ideas, what do i do? And remember, that my stuff is working perfectly.
Here’s the code in full just in case

void FixedUpdate ()
		// Allow the player to select the angle they want
		if(Input.GetAxis(leftStickX) != 0 || Input.GetAxis(leftStickY) != 0)
			// Determine the Quaternion using input from the left analog stick
			Quaternion lookRot = Quaternion.identity;
			lookRot.eulerAngles = new Vector3(Mathf.Atan2(Input.GetAxis(leftStickY), Input.GetAxis(leftStickX)) * Mathf.Rad2Deg,transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z);
			// Set an objects rotation using the above quaternion
			fistArrow.transform.rotation = Quaternion.Lerp(fistArrow.transform.rotation, lookRot, Time.deltaTime * arrowSpeed);
			//GameManager.playerAngleArr[0] = lookRot.eulerAngles.x; // Uncomment later

Don’t worry about it now guys. it sorted itself out…?


I Figured it out (this is a few days late)! Both player characters had the same script and depending on the state of a bool called “isPlayerOne” the script would determine what controls the player got.


public bool isPlayerOne = false;
private string A;

Void Start()
     A = "AP1";
     A = "AP2"

Makes sense right? WELL! The issue was that I hadn’t done that for all of Player 2’s controls. So what i was seeing was player1 work and player2 send the error. YAY!