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
c# unity3d oculus unity3d-editor oculusgo
add a comment |
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
c# unity3d oculus unity3d-editor oculusgo
UseOVRInput.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 withOVRInput.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
add a comment |
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
c# unity3d oculus unity3d-editor oculusgo
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
c# unity3d oculus unity3d-editor oculusgo
asked Nov 8 at 9:51
Ali
34
34
UseOVRInput.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 withOVRInput.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
add a comment |
UseOVRInput.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 withOVRInput.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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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