Unity for OculusGo: Move an object along the z axis by touchpad

301 Views Asked by At

I have written a script to pick an object with a rigidbody component by the ray casted from the controller and move it around. I make the object, the child of the controller to move it in the scene then. I already have a script to detect the object by the ray casted from a controller, picking it up and moving it up and down and left and right with the controller.

Now , I want to make that selected object along the z-axis by using the touchpad of oculus go. However I am not sure how to do it. This is the function i am using it to attach to the parent:

 public virtual void Store(Transform NewParent)
{
    //The following stops the object being effected by physics while it's in 
the players hand
    rb.isKinematic = true;
    //And fixes it to the new parent it is given by the player script to 
follow.
    transform.parent = NewParent;
    //It then resets it's position and rotation to match it's new parent 
object
    //transform.localRotation = Quaternion.identity;
    //transform.localPosition = Vector3.zero;
}

and then i use it in the pointer class to attach it to the ray:

void Intract()
{
    //We set up the input "OculusPrimaryIndexTrigger" in the Input manager
    if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger))
    {
        selectVisual.ClearObject();
        //Check if you are holding something you can throw first
        if (inHand != null)
        {
            inHand.Release(controllerRef.forward, throwForce);
            inHand = null;
            //We do this check here to prevent Errors if you have nothing 
selected
        }
        else if (selectedObject != null)
        {
            //Check if you can pick up the selected object second
            if (selectedObject.GetComponent<PickUp>())
            {
                //Beacuse PickUp is a child of PropBase, we can ask InHand 
to store selectedObject as PickUp, rather than use GetComponent
                inHand = selectedObject as PickUp;
                inHand.Store(holdingRef);
                //If non of the above were valid then simple call the 
trigger function of the selected object
            }
            else
            {
                selectedObject.Trigger();
            }
        }
        //If you have a object that you need to hold down a button to 
intract with
    }

    else if (pointerOver != null)
    {
        if (pointerOver.GetComponent<PropBase>())
        {
            selectedObject = pointerOver.GetComponent<PropBase>();
        }
        else
        {
            selectedObject = null;
        }
    }
    else
    {
        selectedObject = null;
    }

    }

}

If anyone could point me in a right direction or help me with this, I would greatly appreciate it!

Thanks in advance

0

There are 0 best solutions below