Getaxis Unity Code Example


Example 1: get axis mouse unity


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);
}
}

Example 2: unity input get axis


float movement = Input.GetAxis("Horizontal") * speed;

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools