Unity VR Oculus Rift - c#

I have implemented basic player interactions, look, move, grab and move items and it all works fine.
The OVRGrabbable script (part of OVR plugin) makes the grabbed object`s rigidbody kinematic.
As a result, the object in hand is passing through other colliders. When the item is released everything works great but while in hand it passes through all colliders. It does not stop when it hits other colliders resulting passing with the object through a wall and etc.
I know that the OVRGrabbable script makes the object kinematic and that is why this happens. Can I do something to change this default behavior ? I need the object to stop when it hits the table, wall, not to pass through it.
Did anyone tried to solve this? Any advice ?
Thank you.

I have abandoned using the official Oculus SDK. Instead I have implemented VRTK SDK which is working great, and it supports a wider range of VR devices.
If anybody has a similar problem, VRTK solves this problem with colliders and other minor fixes.
https://github.com/thestonefox/VRTK

Related

Unity 2D collision only from above

Im trying to make a simple cloud jumping game with Unity 2D and have faced a problem.
How would i make the player go "through"/"in front of" the cloud when coming under but colliding when coming down again. Or do i need to trigger the jump action somehow when "touching" the cloud without collision?
Thank you in advance. I hope my text was understandable.
I have tried many ways, i don't even know what anymore. Like with ontrigger but idk did i do it right, it didn't work, something with adding a new layer, and polygon collider but how do i even edit it clearly?
I need help :')

Prefab is not direct copy of original

I'm making a 2D platformer and we did all the movement tweaking in a sample scene, so we figured we could make a prefab of the player and just drag it into each other scene when we're designing the levels. But for some reason, the prefab jumps significantly higher than the original and I can't figure out why. As far as I can tell, prefabs should always be an exact duplicate right?
I know public references are easily messed up when using them in a prefab. Have you tried looking through them if you have any? Also anything you set in a serialized field but not in the script itself might have changed as well.

Throwing Objects in Unity Using Vive

I am trying to use the HTC Vive controller to pick up and throw objects in Unity. The idea is that you get the controller close enough to the object to touch it, hold the trigger to pick it up, and release the trigger while making a throwing motion to throw it. I have a script and box collider on the controller, and rigidbodies and box colliders on the objects. If I try to pick up an object, it kind of shakes and bounces, but uncontrollably. I am also having the issue where the objects bounce around randomly in the environment instead of being still. Any suggestions?
Check this Tutorials. It's good, a bit old but for sure will get you on track and show you how it's done.
Video Tutorial - Click me

Getting Movement with Google Cardboard in Unity

I want to put a scene in Unity into virtual reality using Google Cardboard.
I used to be able to just drag a CardboardMain prefab into the scene, delete the main camera, use CardboardMain as the camera position, and CardboardHead to track where the user was looking.
After reading the release notes for the new updates, I thought I could drag a GVREditorEmulator and GVRControllerMain into the scene, and keep the normal camera.
Unfortunately, I can't figure out how to get the camera to follow my character with this new setup. (In this case, a rolling ball.)
If I change the position of the normal camera, it looks like it works fine in Unity, but as soon as I upload it to my phone, the user stays in the same place, while the ball rolls away. (The user can still control the ball's movements, but the camera/user doesn't follow the ball at all.)
I had thought that the chase cam demo would be useful, but that's only for Daydream, and I'm using Cardboard.
This trick seemed to work for some people. I tried in on a previous version of Unity and a previous version of the SDK and it did not seem to work. I may just need to try it on this new version, but I'm worried about going into the released code and editing it, so I'd prefer answers that don't require this.
Is there any way I can get the user to move in a Google Cardboard scene in Unity when I upload it to my iPhone?
UPDATE:
It looks as though my main camera object is not moving, making me think that something is resetting it back to the center every time, lending some more credence to the "trick" earlier. I will now try "the trick" to see if it works.
UPDATE: It doesn't look like the lines listed in the "trick" are there anymore, and the ones that are similar in the new program don't even seem to be running. Still trying to figure out what continues to reset the main camera's position.
UPDATE: Just got a response back from Google on GitHub (or at least someone working on the SDK) that says "You just need to make the node that follows the player a parent of the camera, not the same game object as the camera." I'm not exactly sure what that means, so if someone could explain that, that would most likely solve my problem. If I figure it out on my own I'll post back here.
UPDATE: Zarko Ristic posted an answer that explained what this was, but unfortunately the tracking is still off. I found out how to get Google Cardboard to work with the old SDK and posted an answer on that. Still looking for ways to get the new SDK to follow a character properly.
You can't change positioin of camera in cardboard application, position of MainCamera it always must be 0,0,0. But you can just simply made empty GameObject and make it parent of MainCamera. In Cardboard games actualy you can move parent of camera instead MainCamera directly.
Add script for tracking ball to MainCamera parent (GameObject).
This does not answer my question, but is a solution to the problem.
Do not use the newest version of the SDK. Use version 0.6
When building the app in Unity, do not select to have VR enabled under the build settings. (VR will still be enabled in the app.) (Credit: Zarko Ristic)
When putting the app onto your phone, if XCode prompts you to change any settings, you can ignore it.
In addition, disable bitcode under "Build Settings -> Enable Bitcode -> No" (Currently, this will not allow you to put your app onto the app store. I would greatly appreciate it if anyone has information on how to get it to run without doing this.)
Now your app should run on your phone correctly.

Unity3D Run Time Error

At the moment I've set up a dual camera scene in Unity. I've created an empty game object for my camera's to inherit from and attached some of the first person controller scripts to this empty game object.
When I run the program in the editor, it runs fine. When I build the project, the game crashes and my camera objects fall through the ground. I've never experienced something like this before in Unity. Attached is a copy of my my current fps set up values.
In the picture, you will see that I have turned gravity off (set it to 0), yet it still falls down when I run the built program.
Has anyone ever come across something like this before? I've spent all day trying to fix this, but I'm getting no where.
I experienced such an issue when my parent object (I usually use capsules to "carry" the camera as the players head like 1.70m above the ground) is set to low ... what happens if you move your camera-guy together with the game object one meter upwards? (so that he falls down a bit against the surface when you start).
Maybe there is a difference in some relations between editor-build and release-build.
Or, in case this isn't the solution, check the spatial positions of your involved objects again. Falling through a terrain is often produced by misplaced reference objects. (I sometimes hung a carrier object under a camera instead of hanging the camera under a carrier object.)
As you say that it works in the editor-build i assume that you have activated collision for the relevant objects.

Categories