Answers for "get axis unity"

3

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);
    }
}
Posted by: Guest on March-28-2020
0

unity input get axis

float movement = Input.GetAxis("Horizontal") * speed;
Posted by: Guest on March-13-2020
0

get axis unity

using UnityEngine;
using System.Collections;

public class AxisRawExample : MonoBehaviour
{
    public float range;
    public GUIText 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");  
    }
}
Posted by: Guest on July-08-2021

Browse Popular Code Answers by Language