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
Related
Forgive me if there is already another post addressing something like this, but I haven't found it yet. I'm trying to get my object to ignore the default gravity field and move between the walls of the pipe in the image below:
The effect I'm trying to achieve is to allow my player (cube) to exit with a different rotation/spin when leaving the pipe as it falls back toward the ground.
I've seen an attractor script for planetary bodies elsewhere, but I'm not sure those apply to this scenario or not. Obviously, I'm planning on using a mesh collidor for my pipeline in the image (I created this in Blender) and the faces are inverted.
If I need to create a script for this, where would I start? Which object would I apply this script to and in which way?
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
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.
I am making a 2d game in Unity, and for the main character I have created 4 animations; up, down, left, and right. To do this I just made the animation and trigger them with a line of code like this:
anim.SetBool ("movingUp", true);
which would happen when the up key is pressed. This type of animation is easy to deal with because it is not based on time, but how long the player wants the character to be in that state. I am now trying to add an animation that is triggered when the character collides with another game object. I am not sure how to make it so the animation will play just one time and then go back to the other animation. Is there a way to trigger an animation to play just once in Unity?
Generally speaking you don't have to code your own controller, Unity already has that one and here is the link to official Unity tutorials how to use it. What you need is to fire off a trigger just like you did upon collision and check has exit time on that animation in the controller. After that you just guide the state back to the animation you want it to go back to. Again, accurate and thorough tutorials are found online on the term Unity Mecanim how to or Animations in Unity or something like that.
MAke an animator controller and add the 4 animations into it. then make a transition between them with the Boolean. Are you doing this as an automatic animation without triggering it?
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.