Unity для OculusGo: перемещение объекта вдоль оси z с помощью сенсорной панели - PullRequest
0 голосов
/ 08 ноября 2018

Я написал скрипт, чтобы выбрать объект с компонентом твердого тела лучом, отлитым из контроллера, и переместить его.Я делаю объект, потомок контроллера, чтобы затем переместить его в сцену.У меня уже есть скрипт для обнаружения объекта по лучу, отлитому из контроллера, взятия его вверх и перемещения вверх и вниз, влево и вправо с контроллером.

Теперь я хочу сделать выбранный объект вдоль оси z с помощью сенсорной панели Oculus Go.Однако я не уверен, как это сделать.Это функция, которую я использую для присоединения к родителю:

 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;
}

, а затем я использую ее в классе указателей для присоединения к лучу:

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;
    }

    }

}

Если кто-нибудьмог бы указать мне правильное направление или помочь мне в этом, я был бы очень признателен!

Заранее спасибо

...