I am trying to get the distance value from the proximity sensor by using unity’s Input System but nothing that I tried seems to work. I tried looking into the documentation, there it says something about “AxisControl” but I have no clue how to code it to work.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.ProximitySensor.html
This my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using TMPro;
using System;
public class Sensors : MonoBehaviour
{
public TMP_Text textprox;
public ProximitySensor proximity;
void Start()
{
proximity = ProximitySensor.current;
}
void Update()
{
if(proximity != null)
{
InputSystem.EnableDevice(proximity);
var _ProximitySensor = ProximitySensor.current;
var _dist = _ProximitySensor.distance;
textprox.text = "Proxy: " + _dist;
}
else
{
textprox.text = "null";
}
}
}