• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
Question by bomerman104 · May 14, 2019 at 05:51 AM · vrsteam2.0

SteamVR 2.0 how to get trackpad input

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

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image

Answer by bomerman104 · May 14, 2019 at 07:16 PM

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.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

204 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SteamVR 2.0 how to implement distance grab? 2 Answers

Steam VR: Two Eye Setup. 1 Answer

SteamVR/Pun Networking integration 0 Answers

Steam VR - The correct way for setting up body and head colliders? 0 Answers

Please help me solve the problem with shoot a gun(HTC VIVE) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges