unity c# input code example
Example 1: unity how to get input
using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour
{
public void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Debug.Log(Input.mousePosition);
}
}
}
Example 2: how to get joypad axis input unity
float moveSpeed = 10;
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
transform.Translate(new Vector3(horizontalInput, 0, verticalInput) * moveSpeed * Time.deltaTime);