I have a knob which is attached as joystick to my computer. I can rotate it 360 + Deg.
I would like to use it in unity, sadly i can only attach it as a joystick axes so it gives me values from -1 / 0 / 1.
My idea was to reset axes when e.g. -1 is reached and add another -1 so i end up at -2 which would be 180 deg.
Sadly Input.ResetInputAxes(); is not working at all.
Is there any
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class joystick : MonoBehaviour {
private float axis = 0.0f;
private float axisold = 0.0f;
private float rot = 0.0f;
private float degree = 90.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
axis = (Input.GetAxisRaw("Horizontal"));
rot = (axisold + axis) * degree;
Debug.Log(axis);
transform.eulerAngles = new Vector3(90.0f, 0.0f, rot);
if (axis == -1.0f || axis == 1.0f) {
axisold = axis;
Input.ResetInputAxes(); // NOT WORKING
axis = 0.0f;
rot = 0.0f;
}
}
}
way i could use my knob to habe the rotation equivalent?