---
title: "GetAxis"
content_type: tutorial
url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o?language=en"
language: en
container_type: course
container_title: "Beginner Scripting"
container_url: "https://learn.unity.com/course/beginner-scripting.md?language=en"
standalone_markdown_url: "https://learn.unity.com/tutorial/getaxis-o.md?language=en"
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/course/beginner-scripting/tutorial/getaxis-o.md?language=en&version=4.x"
last_updated: "2026-08-04T14:23:50.000Z"
---

# GetAxis

Learn to read axis-based input with GetAxis and adjust axes in the Input Manager for responsive controls.

How to "get axis" based input for your games in Unity and how these axes can be modified with the Input manager

This tutorial is included in the [Beginner Scripting project](https://learn.unity.com/project/beginner-gameplay-scripting).

Previous: [GetButton and GetKey](https://learn.unity.com/tutorial/getbutton-and-getkey?projectId=5c8920b4edbc2a113b6bc26a)

Next: [OnMouseDown](https://learn.unity.com/tutorial/onmousedown?projectId=5c8920b4edbc2a113b6bc26a)

## 1. GetAxis

[Video](https://connect-mediagw.unity.com/h1/20220104/videos/c9b3bbba-1096-418a-a059-2697847064c9_U_Beginner_16_GetAxis.mp4)

## **AxisExample**

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class AxisExample : MonoBehaviour
{
    public float range;
    public Text textOutput;
    
    
    void Update () 
    {
        float h = Input.GetAxis("Horizontal");
        float xPos = h * range;
        
        transform.position = new Vector3(xPos, 2f, 0);
        textOutput.text = "Value Returned: " + h.ToString("F2");  
    }
}
```

## **AxisRawExample**

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class AxisRawExample : MonoBehaviour
{
    public float range;
    public Text textOutput;
    
    
    void Update () 
    {
        float h = Input.GetAxisRaw("Horizontal");
        float xPos = h * range;
        
        transform.position = new Vector3(xPos, 2f, 0);
        textOutput.text = "Value Returned: " + h.ToString("F2");  
    }
}
```

## **DualAxisExample**

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class DualAxisExample : MonoBehaviour 
{
    public Text horizontalValueDisplayText;
    public Text verticalValueDisplayText;
    public float hRange;
    public float vRange;
    
    void Update ()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        float xPos = h * hRange;
        float yPos = v * vRange;
        
        transform.position = new Vector3(xPos, 0, vPos);
        horizontalValueDisplayText.text = h.ToString("F2");
        verticalValueDisplayText.text = v.ToString("F2");
    }
}
```
