Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 N0kta · Apr 05 at 11:08 AM · transformvrinteractiongrabinteractable

Cant get Attach Transform of interactorObject.

I was following this tutorial: https://www.youtube.com/watch?v=XRaNYOXU0hw Code:

using UnityEngine; using UnityEngine.XR.Interaction.Toolkit; public class OffsetInteractable : XRGrabInteractable { protected override void OnSelectEntering(SelectEnterEventArgs args) { base.OnSelectEntering(args); MatchAttachPoint(args.interactor); } private void MatchAttachPoint(XRBaseInteractor interactor) { bool isDirect = interactor is XRDirectInteractor; attachTransform.position = isDirect ? interactor.attachTransform.position : transform.position; attachTransform.rotation = isDirect ? interactor.attachTransform.rotation : transform.rotation; } }

And everything works just fine but it says that args.interactor is Obsolete and instead interactorObject should be used. Even though it works fine like this, I didn't want to have an Obsolete method.

I tried using private void MatchAttachPoint(IXRInteractor interactor) { bool isDirect = interactor is XRDirectInteractor; attachTransform.position = isDirect ? GetAttachTransform(interactor).position : transform.position; attachTransform.rotation = isDirect ? GetAttachTransform(interactor).rotation : transform.rotation; }

and private void MatchAttachPoint(IXRInteractor interactor) { bool isDirect = interactor is XRDirectInteractor; Transform GrabTransform = GetAttachTransform(interactor); attachTransform = isDirect ? GrabTransform : transform; }

but couldn't achieve the desired effect as shown in the video.

It's also said in Unity docs that IXRInteractor interactorObject should be used instead of XRBaseInteractor interactor. https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/api/UnityEngine.XR.Interaction.Toolkit.BaseInteractionEventArgs.html https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/api/UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.html
Any help appreciated

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 Avinoamaj · Apr 28 at 09:32 AM

Hey, I just figured it out: first, you're gonna have to use "SelectEnterEventArgs args" and "SelectExitEventArgs args" respectively in all of the functions. In the 2.0.0+ versions of the XR toolkit, they refer to the selection of an object as an "event object" which means the "args" will contain both your interactor and your interactable (the "hand" and the selected element).

now, every time you need to refer to the Attach Point between the interactor and the interactable you can use this: args.interactorObject.GetAttachTransform(args.interactableObject)

(continuing with either .position / .localposition or .rotation / .localrotation)

the rest of the script remains pretty much the same.

I'll attach my complete updated script as a TXT file here.

,Hey, I just figured it out: first, you're gonna have to use "SelectEnterEventArgs args" and "SelectExitEventArgs args" respectively in all of the functions. In the 2.0.0+ versions of the XR toolkit, they refer to the selection of an object as an "event object" which means the "args" will contain both your interactor and your interactable (the "hand" and the selected element).

now, every time you need to refer to the Attach Point between the interactor and the interactable you can use this: args.interactorObject.GetAttachTransform(args.interactableObject)

(continuing with either .position / .localposition or .rotation / .localrotation)

the rest of the script remains pretty much the same. I'll attach my complete updated script as a TXT file here.


graboffset.txt (1.9 kB)
graboffset.txt (1.9 kB)
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

222 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 avatar image avatar image avatar image avatar image avatar image avatar image 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

XR Interaction Toolkit - Grab Object Persistent 0 Answers

How to make audio interact with visual in VR? VRTK 0 Answers

[Unity VR] Interactive moving box with functional lid? 0 Answers

XRGrabInteractable track velocity, not position 0 Answers

how to use vrgaze to change the color of the cube 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