You are on page 1of 1

Manual Scripting API Search scripting...

Version: 2020.3 C#
JointMotor
JointMotor2D
JointSpring Input
Input.GetAxis
.GetAxis
JointSuspension2D Leave feedback
JointTranslationLimits2D
JsonUtility Declaration
Keyframe public static 5oat GetAxis
GetAxis(string axisName
axisName);
LayerMask
LazyLoadReference<T0>
LensFlare Description
Light Returns the value of the virtual axis identiAed by axisName .

LightBakingOutput
The value will be in the range -1...1 for keyboard and joystick input devices.
LightingSettings
LightmapData The meaning of this value depends on the type of input control, for example with a joystick's horizontal axis a value of 1
means the stick is pushed all the way to the right and a value of -1 means it's all the way to the left; a value of 0 means the
LightmapSettings
joystick is in its neutral position.
LightProbeGroup
LightProbeProxyVolume If the axis is mapped to the mouse, the value is different and will not be in the range of -1...1. Instead it'll be the current mouse
LightProbes delta multiplied by the axis sensitivity. Typically a positive value means the mouse is moving right/down and a negative value
LineRenderer means the mouse is moving left/up.

LineUtility
This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.
LocalizationAsset
LocationInfo To set up your input or view the options for axisName , go to Edit > Project Settings > Input Manager
Manager. This brings up the
LocationService Input Manager. Expand Axis to see the list of your current inputs. You can use one of these as the axisName . To rename the
input or change the positive button etc., expand one of the options, and change the name in the Name Aeld or Positive
LOD
Button Aeld. Also, change the Type to Joystick Axis
Axis. To add a new input, add 1 to the number in the Size Aeld.
LODGroup
Logger
using UnityEngine;
MasterServer
using System.Collections;

// A very simplistic car driving on the x-z plane.

public class ExampleClass : MonoBehaviour


{
public float speed = 10.0f;
public float rotationSpeed = 100.0f;

void Update()
{
// Get the horizontal and vertical axis.
// By default they are mapped to the arrow keys.
// The value is in the range -1 to 1
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;

// Make it move 10 meters per second instead of 10 meters per frame...


translation *= Time.deltaTime;
rotation *= Time.deltaTime;

// Move translation along the object's z-axis


transform.Translate(0, 0, translation);

// Rotate around our y-axis


transform.Rotate(0, rotation, 0);
}
}

using UnityEngine;
using System.Collections;

// Performs a mouse look.

public class ExampleClass : MonoBehaviour


{
float horizontalSpeed = 2.0f;
float verticalSpeed = 2.0f;

void Update()
{
// Get the mouse delta. This is not in the range -1...1
float h = horizontalSpeed * Input.GetAxis("Mouse X");
float v = verticalSpeed * Input.GetAxis("Mouse Y");

transform.Rotate(v, h, 0);
}
}

Note: The Horizontal and Vertical ranges change from 0 to +1 or -1 with increase/decrease in 0.05f steps. GetAxisRaw has
changes from 0 to 1 or -1 immediately, so with no steps.

Did you And this page useful? Please give it a rating:

Report a problem on this page

Is something described here not working as you expect it to? It might be a Known Issue
Issue. Please check with the Issue Tracker at

issuetracker.unity3d.com .

By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site
Copyright ©2021 Unity Technologies. Publication Date: 2021-09-17. Cookies Settings Accept All Cookies
navigation, analyze site usage, and assist in our marketing efforts.
Tutorials Community Answers Knowledge Base Forums Asset Store

You might also like