Search Unity

Attach object to controller

Discussion in 'AR/VR (XR) Discussion' started by Toobor, Nov 22, 2018.

  1. Toobor

    Toobor

    Joined:
    Sep 25, 2018
    Posts:
    1
    Hello,
    I am experimenting with the plant script that is available in the sample model in SteamVR 2.0. I want the flower to be created in the hand and keep being in the hand until I release the trigger. I have succeeded to create the flower in the same place as the hand but I have not manage to get the flower to stay in the hand. Instead it falls to the ground. I guess the solution is to make the flower a child of the controller. I tried the following code:
    Code (CSharp):
    1. planting.transform.parent = hand.transform
    but the flower still falls to the ground. Also I want the flower to be throwable in the same way as it is when I pick it up from the ground which I guess it is not if i just make the plant a child. Instead I was thinking to use the AttachObject method that is in the Hand script, is this the right way to go? If so, how do I write the input-parameters (especially the flags)? Or is there another way?

    Thank you for your help!