Input not registering in Unity

Started by
6 comments, last by CaseyHardman 11 years, 6 months ago
Im new to Unity and I was using a tutorial to make a 2d platformer. Everything was going well until I tried to add jumping and crouching. For some reason I get this error when trying to run the game.

UnityException: Input Axis Veritcal is not setup.
To change the input settings use: Edit -> Project Settings -> Input
playerControls.Update () (at Assets/2D Mario Assets/Scripts/playerControls.js:66)


Im not sure why this happens but even when I go into input settings and try to change it, it still doesn't work.
It only seems to jump when pressing the left or right arrow keys(which is to move left and right) while pressing the jump keys.
Any idea on why this is happening?

[source lang="jscript"]var runSpeed : float = 6.0;
var fallSPeed : float = 2.0;
var walkJump : float = 6.3;
var runJump : float = 10;
var crouchJump : float = 12;
var gravity : float = 20.0;

var startPos : float= 0;
var moveDirection : int=1;

//aniPlay.aniSprite(16,16,0,0,16,12);

private var velocity : Vector3 = Vector3.zero;
function Update()
{
var aniPlay=GetComponent("aniSprite");
var controller : CharacterController = GetComponent (CharacterController);
if(controller.isGrounded)
{
velocity = Vector3(Input.GetAxis("Horizontal"),0,0);

//Animation

if (velocity.x==0 && moveDirection == 1) //idle right
{
aniPlay.aniSprite(16,16,0,0,16,12);
}

if (velocity.x==0 && moveDirection == 0) //idle Left
{
aniPlay.aniSprite(16,16,0,1,16,12);
}

if (velocity.x<0) //Walk left
{
velocity*=WalkSpeed;
aniPlay.aniSprite(16,16,0,3,10,15);
}

if (velocity.x>0) //Walk Right
{
velocity*=WalkSpeed;
aniPlay.aniSprite(16,16,0,2,10,15);
}

if (velocity.x<0 && Input.GetButton("Fire1")) //run Left
{
velocity *=runSpeed;
aniPlay.aniSprite(16,16,0,5,16,24);

}
if (velocity.x>0 && Input.GetButton("Fire1")) //run Right
{
velocity *=runSpeed;
aniPlay.aniSprite(16,16,0,4,16,24);
}

if (velocity.x ==0 && Input.GetAxis("Veritcal")<0) //Crouching
{
print("Crouching");
aniPlay.aniSprite(16,16,0,9,16,24);
}


//Movement
if(Input.GetButton("Jump")&& !Input.GetButton("Fire1"))
{
velocity.y = walkJump;
print("are you Here");
}
if(Input.GetButtonDown("Jump") && Input.GetButton("Fire1"))
{
velocity.y=runJump;
}
}

if (!controller.isGrounded)
{
velocity.x = Input.GetAxis("Horizontal");
velocity.x *= WalkSpeed;
}
if (velocity.x<0) //get last move Dir left
{
moveDirection=0;
}
if (velocity.x>0)
{
moveDirection=1; //get last move dir right
}

velocity.y-=gravity*Time.deltaTime; //apply gravity
controller.Move(velocity*Time.deltaTime); //move the controller

}
[/source]

[source lang="jscript"]
//Movement
if(Input.GetButton("Jump")&& !Input.GetButton("Fire1"))
{
velocity.y = walkJump;
print("are you Here");
}
if(Input.GetButtonDown("Jump") && Input.GetButton("Fire1"))
{
velocity.y=runJump;
}
}

if (!controller.isGrounded)
{
velocity.x = Input.GetAxis("Horizontal");
velocity.x *= WalkSpeed;
}
if (velocity.x<0) //get last move Dir left
{
moveDirection=0;
}
if (velocity.x>0)
{
moveDirection=1; //get last move dir right
}

velocity.y-=gravity*Time.deltaTime; //apply gravity
controller.Move(velocity*Time.deltaTime); //move the controller

}
[/source]
Advertisement
Can you post the code you're using that causes the error?

What did you do to the input settings when you say you "tried to change it"?

[twitter]Casey_Hardman[/twitter]

Okay I put it up. All i tried to do was change the jump button to up and the vertical inputs were up and down.
I've been tinkering around with the code and its seems that the problem has to do with this code:
if (velocity.x ==0 && Input.GetAxis("Veritcal")

is there a reason that affects the jumping?
Typo? "Veritcal" > "Vertical"
I used Unity 2 back in the day, and I've never had this problem, so I believe the man above is correct. However things have changed, so I don't know. If fixing the typo doesn't get rid of the error, try going to Edit->Project Settings->Input to fix it. Just go through the drop down boxes in the top left corner.

I'm a game programmer and computer science ninja !

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here !

your right Im sorry I thought it was correct
Also, in your "walk left" and "run right" code, you have:

if (velocity.x0)

and

if (velocity.x0 && Input.GetButton("Fire1"))

Aren't you missing signs like > and < here?


So did fixing the typo make the jumping work?

[twitter]Casey_Hardman[/twitter]

This topic is closed to new replies.

Advertisement