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











up vote
0
down vote

favorite












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










share|improve this question






















  • Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
    – Remi
    Nov 9 at 0:38










  • I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
    – Ali
    Nov 9 at 9:04












  • Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
    – Remi
    Nov 9 at 9:42












  • I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
    – Ali
    Nov 9 at 10:04















up vote
0
down vote

favorite












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










share|improve this question






















  • Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
    – Remi
    Nov 9 at 0:38










  • I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
    – Ali
    Nov 9 at 9:04












  • Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
    – Remi
    Nov 9 at 9:42












  • I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
    – Ali
    Nov 9 at 10:04













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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










share|improve this question













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







c# unity3d oculus unity3d-editor oculusgo






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 9:51









Ali

34




34












  • Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
    – Remi
    Nov 9 at 0:38










  • I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
    – Ali
    Nov 9 at 9:04












  • Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
    – Remi
    Nov 9 at 9:42












  • I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
    – Ali
    Nov 9 at 10:04


















  • Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
    – Remi
    Nov 9 at 0:38










  • I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
    – Ali
    Nov 9 at 9:04












  • Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
    – Remi
    Nov 9 at 9:42












  • I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
    – Ali
    Nov 9 at 10:04
















Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
– Remi
Nov 9 at 0:38




Use OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad); to retrieve the position of your finger on the touchpad (a Vector2 from -1.0f to 1.0f), then move your object accordingly.
– Remi
Nov 9 at 0:38












I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
– Ali
Nov 9 at 9:04






I used something like this inside the interact function but didn't work: holdingRef.transform.Translate(new Vector3(0, 0, OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad).y));
– Ali
Nov 9 at 9:04














Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
– Remi
Nov 9 at 9:42






Does it work with OVRInput.Axis2D.PrimaryThumbstick? You should log the values to see if you get the correct values...
– Remi
Nov 9 at 9:42














I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
– Ali
Nov 9 at 10:04




I am using it on oculus go, which doesn't have primarythumbstick. also since i am using touchpad to move and can only test it after building this to the device, will the debug work?
– Ali
Nov 9 at 10:04

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205194%2funity-for-oculusgo-move-an-object-along-the-z-axis-by-touchpad%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205194%2funity-for-oculusgo-move-an-object-along-the-z-axis-by-touchpad%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff