Input.GetAxisRaw = only 2 choices (horizontal or vertical)?

Hi everyone, got a question regarding the Input.GetAxisRaw command. Are “Horizontal” and “Vertical” the only two choices available? I’m working on the 2D Platformer tutorial and am adding my own twist to the game. I have Lerpz moving and jumping well on the horizontal but I want the player to have a choice of either pressing the UP arrow or DOWN arrow and the camera will shift either up or down. When it comes to vertical, the camera moves only up with the code below. How can I make the camera move down as well? Any help would be highly appreciated, thanks in advance. NOTE: I’m still a javascript rookie :slight_smile:

2D Platformer tutorial:

function UpdateSmoothedMovementDirection () {	
	var h = Input.GetAxisRaw ("Horizontal");
	
	if (!canControl)
		h = 0.0;
	
	movement.isMoving = Mathf.Abs (h) > 0.1;
		
	if (movement.isMoving)
		movement.direction = Vector3 (h, 0, 0);
		
                // return camera to normal eye level
                CameraTargetAttributes.heightOffset = 2;
		
	var v = Input.GetAxisRaw ("Vertical");
	
	if (!canControl)
		v = 0.0;
		
	movement.isLookingUp = Mathf.Abs (v) > 0.1;	
	
	if (movement.isLookingUp)
	  // move camera up	
          CameraTargetAttributes.heightOffset = 4;
	
	var d = Input.GetAxisRaw ("Vertical");
	
	if (!canControl)
		d = -0.0;
		
	movement.isLookingDown = Mathf.Abs (d) < 0.0;
	
	if (movement.isLookingDown)
                // move camera down
		CameraTargetAttributes.heightOffset = -4;

Well no.
In the unity editor
Goto Edit->Project Settings->Input
Now there are as many virtual axis as you want. Here you can rename them, change there bindings or what have you. Want to add one simply do the usual cntrl+D

Hi aiursrage2k, I have the Input Manager open and see the two axes: horizontal and vertical. Each has a negative and positive button with left, right, down and up. So what you’re saying is I can just rename the vertical negative button ‘down’ to say ‘isLookingDown’ and the code will work? Sorry if I don’t quite understand, I’m trying to though.

You probably want to click on the help icon in the Input Manager panel.

–Eric

Have a look here, too.

Sweet, thanks all for the help, gonna go add a ‘down’ axis and work on the code a bit. I’ll let you know how it works out.

Thanks again.

SUCCESS!!! Yoohoo, got it to work. Here’s what I did, hope this helps others.
Added 2 new inputs into the Input.Manager: ‘Up’ and ‘Down’. Here’s the modified javascript code:

function UpdateSmoothedMovementDirection () {	
	var h = Input.GetAxisRaw ("Horizontal");
	
	if (!canControl)
		h = 0.0;
	
	movement.isMoving = Mathf.Abs (h) > 0.1;
		
	if (movement.isMoving)
		movement.direction = Vector3 (h, 0, 0);
		CameraTargetAttributes.heightOffset = 2;
		
	var vUp = Input.GetKey ("up");
		if (vUp)
		CameraTargetAttributes.heightOffset = 4;
		
	var vDown = Input.GetKey ("down");
		if (vDown)
		CameraTargetAttributes.heightOffset = 0;

Thanks again for all the help. VIVA UNITY!!!