Search Unity

Question Change scale when grabbed

Discussion in 'XR Interaction Toolkit and Input' started by AnahidE5, Dec 16, 2022.

  1. AnahidE5

    AnahidE5

    Joined:
    Jan 10, 2022
    Posts:
    40
    I'm making an app on Pico 3 using XR interaction toolkit 2.2. I've added a XR Grab Interactable to my object. I want the object to get smaller when I grab it. So I have a function that gets called on Select Entered that changes the scale. But It doesn't work. The function can do other things though, e.g. show on a text what the new scale is going to be. But it doesn't actually change the object scale. Is there a restriction on that? (Like if there is an active animator, the parameters involved in it can't be changed or something like that?)

    Edit: I'm now realizing in the newer XR interaction toolkit there are IXRGrabTransformers and I can't keep using my old method for changing scale. However, still not sure how to use this since I can't find examples. Any help would be appreciated.
     
    Last edited: Dec 16, 2022
  2. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    Greetings. I ran into this issue today as well. It appears, an item is not scalable while it is grabbed. I don't know yet if there is a way around this. If you've found one, please let me know. I was banging my head trying to figure out why my simple logic wasn't working, until I just tried changing the gameobject's scale in the inspector while I was holding on to it, and I couldn't.
     
  3. ericprovencher

    ericprovencher

    Unity Technologies

    Joined:
    Dec 17, 2020
    Posts:
    261
    This is supported with the new xr general grab transformer in xri 2.3. You have to manually add the component at edit time and enable 2 handed scaling.
     
  4. ericprovencher

    ericprovencher

    Unity Technologies

    Joined:
    Dec 17, 2020
    Posts:
    261
    AnahidE5 likes this.
  5. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
  6. ericprovencher

    ericprovencher

    Unity Technologies

    Joined:
    Dec 17, 2020
    Posts:
    261
    Yeah that should work fine. Glad you found a resolution
     
  7. FarmerInATechStack

    FarmerInATechStack

    Joined:
    Dec 28, 2020
    Posts:
    57
    I hadn't considered the Uniform Scale Affordance receiver, but will check that. Thank you for the question and tip!

    Scaling a parent object sounds like that should work too. What I did was create a subclass of the Interactable and override the Process methods. Those seem to work sort of like an "Update" method but specifically process the parts of the interactable that the interaction systems need (handling the transform, interaction status, etc). It works and is a solution via code/script if you prefer that.

    VR with Andrew has some YouTube tutorials on Custom Interactors in which he subclasses some of XRI too, but I don't think he shows scaling specifically.