I’m a little desperate for help here as I cannot for the life of me figure out how to get this stuff working.
essentially what I’m trying to do is get the trackpad input from the controller to move the player in the direction that the trackpad is being pressed. I’m struggling to figure out how to actually get the vector input from the track pad and actually do something with it.
I have set-up the Action set for the track pad in the SteamVR Input under the default action set however I am lost after this point
So I managed to figure out how to get the input from the track pad using the following code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
using Valve.VR.InteractionSystem;
public class VRController : MonoBehaviour
{
//variables controlling the the character speed of the player
public float m_Sensitivity = 0.1f;
public float m_MaxSpeed = 1.0f;
//Variable for grabbing the desired actionset
public SteamVR_ActionSet m_ActionSet;
// varaibles for storing if the touchpads have been used on the controller
public SteamVR_Action_Vector2 m_TouchPosition;
// varaible for storing player speed
private float m_Speed = 0.0f;
// varaible for storing the character controller
private CharacterController m_CharacterController = null;
//location values for the player position and the head position
private Transform m_CameraRig = null;
private Transform m_Head = null;
//sets the deadzone for how far the player needs to move their thumb before
public Vector2 m_deadzone = new Vector2(0.1f,0.1f);
public Vector2 m_NeutralPosition = new Vector2(0.0f,0.0f);
private void Awake()
{
m_CharacterController = GetComponent<CharacterController>();
}
// Start is called before the first frame update
void Start()
{
m_CameraRig = SteamVR_Render.Top().origin;
m_Head = SteamVR_Render.Top().head;
}
// Update is called once per frame
void Update()
{
HandleHead();
CalculateMovement();
HandleHeight();
#region Vector2 Action
Vector2 delta = m_TouchPosition[SteamVR_Input_Sources.LeftHand].delta;
if(delta.x >= (m_NeutralPosition.x + m_deadzone.x) && delta.y >= (m_NeutralPosition.y + m_deadzone.y))
{
Debug.Log("Player is moving right and up");
}
#endregion
}
however from here I have kind of hit another dead end as I’m not sure how to move the character based on the direction the thumb is on the touchpad.