• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
mk.jr.fan

Input not registering in Unity

7 posts in this topic

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
0

Share this post


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

Share this post


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

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

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
0

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0