HTC Vive controllers - Sorry for being a NOOB

I have seen and made scripts to push and use triggers on controllers.

But I just want the coordinates of the left or fight controller.

the aim is simple to move a controller and move an object in the room with out touching or colliding with it.

This is very easy… I’m just being a noob.

Thanks

I think the controllers are always index 0 for left an 1 for right but I’ve not got access to Unity or a Vive to check. You could also have the same script on both controllers with a public variable for the controller and just drag the left controller onto the slot in the inspector for the script on the left controller (and do the same for the right).

public SteamVR_TrackedObject controller;

Then you can get the the controller.transfrom.position and controller.transfrom.forward and raycast to an object and remote control based on rays position at the distance it hits. Sorry it’s a bit abstract I’ve not got time to plan it all correctly ATM. Just some ideas really.

You can also look at the name for the device as it contains either Left or Right but you’d be better with the index or the public variable method as the name is out of your hands and could change at any time.

I believe that the hmd is always index 0. I have this code attached to each controller to get the index:

void Awake()
    {
        trackedController = GetComponent<SteamVR_TrackedObject>();
    }
 
     
    void Update () {
        controllerIndex = (uint)trackedController.index;
        device = SteamVR_Controller.Input((int)controllerIndex);
}

I believe that is in some of the sample scenes.

It is simply the position of the GameObject Controller (left) or Controller (right) if you are using the standard camera rig

Thank you all.

I will give it a go.

sorry for over complicating it. Just go to the subobject model of the Controller and add a collider to it!

If you want it to perfectly match the controller there are examples with the actual model of the controller and you can add mesh colliders to it.