• Advertisement
Sign in to follow this  

Input not registering in Unity

This topic is 1924 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
[CODE]
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)
[/CODE]

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] Edited by mk.jr.fan

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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. Edited by superman3275

Share this post


Link to post
Share on other sites
Also, in your "walk left" and "run right" code, you have:

[CODE]if (velocity.x0)[/CODE]

and

[CODE]if (velocity.x0 && Input.GetButton("Fire1"))[/CODE]

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


So did fixing the typo make the jumping work?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement