Jump to content

  • Log In with Google      Sign In   
  • Create Account

Input not registering in Unity


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 mk.jr.fan   Members   -  Reputation: 538

Like
0Likes
Like

Posted 11 October 2012 - 06:20 PM

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]

Edited by mk.jr.fan, 12 October 2012 - 04:20 PM.


Sponsor:

#2 Casey Hardman   Crossbones+   -  Reputation: 2207

Like
1Likes
Like

Posted 11 October 2012 - 08:25 PM

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"?

#3 mk.jr.fan   Members   -  Reputation: 538

Like
0Likes
Like

Posted 12 October 2012 - 04:19 PM

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.

#4 mk.jr.fan   Members   -  Reputation: 538

Like
0Likes
Like

Posted 13 October 2012 - 09:26 AM

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?

#5 Arthur Souza   Members   -  Reputation: 1418

Like
0Likes
Like

Posted 13 October 2012 - 12:45 PM

Typo? "Veritcal" > "Vertical"

A.

Lotus - Action RPG In development http://www.gamedev.n...die-rpg-engine/ |
Personal blog In Portuguese: lotuzgames.wordpress.com |


#6 superman3275   Crossbones+   -  Reputation: 2011

Like
0Likes
Like

Posted 13 October 2012 - 04:45 PM

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, 13 October 2012 - 04:45 PM.

I'm a game programmer and computer science ninja ph34r.png!

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 smile.png!


#7 mk.jr.fan   Members   -  Reputation: 538

Like
0Likes
Like

Posted 13 October 2012 - 08:37 PM

your right Im sorry I thought it was correct

#8 Casey Hardman   Crossbones+   -  Reputation: 2207

Like
0Likes
Like

Posted 13 October 2012 - 11:13 PM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS