Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by FullMe7alJacke7 · Dec 01, 2018 at 02:25 AM · vrsteamtracking

Steam VR 2.0 - Unity 2018+ Controller tracking & architecture question

I've been working on the items and combat system for my VR RPG/RTS game for a few days now and I've spent a good portion of that time digging through Valve's code in order to understand what it does due to lack of updated documentation. Everything I find is out dated, even most questions I can find are as well.

I've went into the SVR2 Hand script and exposed the renderModelInstance variable by making it public and moving it to the global area in the class. This to me feels like a "hacky" way to get the hand and attach my weapon to it...

 public class Halper : MonoBehaviour {
     public Interactable triggeringObject;
     private Hand[] myHands;
     GrabTypes myGrabTypes;
     Interactable temp;
 
     // Use this for initialization
     void Start ()
     {
         myGrabTypes = GrabTypes.Trigger;
         myHands = FindObjectOfType<Player>().GetComponent<Player>().hands;
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.GetKeyDown(KeyCode.Space))
         {
             temp = Instantiate(triggeringObject);
             myHands[0].AttachObject(temp.gameObject, myGrabTypes, Hand.AttachmentFlags.SnapOnAttach | Hand.AttachmentFlags.ParentToHand, null);
             temp.gameObject.transform.SetParent(myHands[0].renderModelInstance.transform);
             temp.transform.position = myHands[0].renderModelInstance.transform.position;
         }
     }
 }

If I don't attach it DIRECTLY to this RenderModelInstance it doesn't attach the weapon to my actual hand because when I run the game the SVR2 scripts don't actually move the hands in the hierarchy, they move the instanced ones that get created at run-time so using Hand.AttachObject in order to do what I thought would be exactly like it sounded, it instead attaches it to the hand in the hierarchy that is static....

I have a ViveCameraRig with a Player script and a Play Area script on it as well as the helper script I wrote (the block above). Then in the hierarchy on the LeftHand & RightHand objects childed to the ViveCameraRig I have the Vive Role Setter script, the Hand script, and the Steam VR_Behavior_Pose script attached to each controller.

But the thing that doesn't make much sense to me other than attachObject not doing as expected was the fact I MUST have the SteamVR_Behavior_Pose script disabled on my controllers because if I enable it my controllers have a really large offset and never line up with the controller.... and if I have it removed it just doesn't make a controller. I assume this behavior is because it's plugged into the Hand script via drag and drop, I just thought would be enabled prior to run-time and had me wondering if that was relating to my positioning problems when trying to attach my weapons to the controller.

I'm well aware the common thought process is "Just use v1".

Comment
Add comment
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

· Add your reply
  • Sort: 
avatar image
0

Answer by hexagonius · Dec 01, 2018 at 12:20 PM

Have you read the readme of the plugin on GitHub?
https://github.com/ValveSoftware/steamvr_unity_plugin

For a more extensive example including picking up, throwing objects, and animated hands see the Interaction System example at ?SteamVR/Interaction System/Samples/Interactions_Example

the pickup functionality should give you what you want.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

126 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

Related Questions

SteamVR has terrible tracking loss in our game 1 Answer

SteamVR 2.3 - Vive controllers aren't tracking after scene load 1 Answer

Pun2 and SteamVR 2.0 integration? 3 Answers

SteamVR Make Game have a 3D Scene and VR Scene 0 Answers

How to get size in pixels of an object using SteamVR camera 0 Answers


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