Forum Discussion
muraliv
11 years agoHonored Guest
Move in look direction
Hi,
Iam developing gear VR app with unity platform and oculus sdk.
I have the OVRPlayercontroller in the scene and this navigate well in the scene.
Now instead of interaction, how do i make the camera move in the looking direction to a specific point.
Could someone hep me out on this.
Thanks
Iam developing gear VR app with unity platform and oculus sdk.
I have the OVRPlayercontroller in the scene and this navigate well in the scene.
Now instead of interaction, how do i make the camera move in the looking direction to a specific point.
Could someone hep me out on this.
Thanks
8 Replies
- cyberealityGrand ChampionOne way to do this would be to capture a position along the look vector, and then lerp from the current position.
Here is an example of how to do this.
- Add the following to the top of the OVRPlayerController.cs class (under the other variables around line 97):private float startTime;
private float lerpSpeed = 1.0f;
private float lerpDist = 1.0f;
private float lerpEnd = 0.1f;
private bool lerpPosition = false;
private Vector3 oldPosition;
private Vector3 newPosition;
private float journeyLength;
- Then add this to the end of UpdateMovement() (around line 337):if (Input.GetKeyUp (KeyCode.L)) {
oldPosition = transform.position;
newPosition = transform.position + transform.forward * lerpDist;
journeyLength = Vector3.Distance(oldPosition, newPosition);
startTime = Time.time;
lerpPosition = true;
}
if (lerpPosition) {
float distCovered = (Time.time - startTime) * lerpSpeed;
float fracJourney = distCovered / journeyLength;
transform.position = Vector3.Lerp(oldPosition, newPosition, fracJourney);
if(Vector3.Distance(transform.position, newPosition) < lerpEnd) lerpPosition = false;
}
However, I should mention that automatically moving the camera can cause discomfort for some players and should be avoided if possible. Hope that helps. - muralivHonored GuestHello
Thanks for the code and it worked fine.
Only thing instead of keycode "L" i changed it to touch pad tap, as i am using only the touchpad in the Gear VR device.
The actual requirement is.
Suppose i have gameobject in the scene with a circle texture, when i look at it or when we do a raycast so that i collides with this game object,i want to highlight and when tapped, i want to move in that direction close to that.
Is this possible.
Thanks in advance. - cyberealityGrand ChampionYes, you can. I made an example project that uses raycasting to highlight objects and a simple stereo crosshair. Unfortunately, the code is for Unity 5.1.x first-party VR, so if you are using an older version or the legacy Oculus integration you may have to modify the scripts.
viewtopic.php?f=37&t=24752&p=284071#p284071
It should still show the basic code of how to do it, and you can port to your own script. - muralivHonored GuestOk thanks cyber,
I will look into the code and experiment it.
Could you please let me know whether unity 5.1 fully support oculus SDK. Because when i upgraded and tested it, there were lot of errors thrown and was not able to publish, mainly nullpointer exception errors.
So I had to switch back to unity 4.6 version. - cyberealityGrand ChampionThe version to use is Unity 5.1.1p3 (as of today). With that you should NOT use the Oculus Unity Integration as it will conflict. All you need is a normal 2D camera, and then select "Virtual Reality Supported" in the player settings. You can also import the Oculus Unity Utilities package, as this will give you some helpful scripts but it's not needed.
- smvishHonored GuestHello Cyber,
But without the oculus unity package import,how do I get the OVRPlayercontrol .
Is there any other alternative for this.
Thanks - cyberealityGrand ChampionYou would download the Unity Utilities package, which include helper classes.
https://developer.oculus.com/downloads/ ... for_Unity/ - muralivHonored GuestHi Cyber,
have you seen "Herobound' in the samsung gear VR.
The graphics quality and the text clarity
Any idea, on what software this is done.
is that unity.
We have been asked to bring in that kind of quality.
Could you please help me out so that i can work in that direction to explore more.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago
- 6 months ago