I’ve imported a model, made up of thousands of parts.
I’m using an Oculus Rift.
Add Mesh Collider, add Rigidbody. Add ovrgrabbable script to parts.
You then have to add Is Kinematic in Rigidbody because of an error. I then press play, i can walk up and grab things with the Rift hands, move them around but it will not drop.
Creating objects in Unity and doing this is fine - all works good. Why can’t i do this with imported models - where am i going wrong?
Didn’t you say that you set the rigidbodies to “Is Kinematic”? Like I mentioned, gravity does not work on “Is Kinematic” Rigidbodies. If you set the rigidbody to Kinematic, it’s like you are turning physics off for that object.
If you need the rigidbodies to be kinematic for some reason, than you have to simulate your own gravity using a script or something.
OR you could also write a script that switches “Is Kinematic” off when you drop the object and switches “Is Kinematic” back on you pick it up.
Thanks again kdgalla. I only had to turn that on because of an error. I created a cube in the scene which i want to grab - with rigid body and ovr grabbable i can grab it and when i let go, it falls. No “is kinematic” is needed.
With the imported data, i add rigid body, a mesh collider and ovr grabbable. Hit the play button and get the error “Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5”.
So, i add “is kinematic” - it works, i can grab items but when i let go of the imported data, it stays in the air.
The cube, without “is kinematic” ticked doesn’t throw up an error and works perfectly.
Why do they act differently and how do i fix? Thanks
Did you try just setting the mesh collider to convex? There’s a check box on the mesh collider component and if you click it, Unity will create a simplified, convex mesh collider based on your mesh. That should have resolved the error without you having to change the physics behavior.
Non-convex mesh colliders are extremely performance-heavy. They’re so heavy that that some physics features don’t even work with them, so you’ll want to avoid them as much as possible.
Always use the simplest collider that you can get away with and try to avoid using mesh colliders if at all possible. If you do use a mesh collider, always make it convex. Non-convex mesh colliders are usually only used for static level geometry at a broad level.
If you have an object with a complex shape, one thing you can do is called a “compound collider”. That’s where you add multiple primitive colliders to a single object. This is usually the best performance because primitive colliders, like sphere and box colliders, are much faster than mesh colliders. You can add colliders on child objects too, and the rigidbody on the parent object will act as if all of these little colliders were one big collider.
Did you try just setting the mesh collider to convex?
Indeed i did - the entire CAD model (made up of hundreds of items - it’s a motorbike) just appears as a heap on the ground.
Always use the simplest collider that you can get away with and try to avoid using mesh colliders if at all possible.
Ah, this could be a problem then if i’m using CAD models. I thought about other colliders but they just won’t work if i’m importing huge CAD models.
Maybe i need to change the title of this thread. Unity is pushing CAD use - this must have been thought of. Yeah, i don’t think it is feasible to use any of the primitive colliders.
That shouldn’t happen unless you have a rigidbody on each piece. Is that the case? Are you trying to make it so that you don’t just grab the whole bike, but you can grab little pieces of the bike instead? Take the bike apart piece, by piece?
“CAD use” could mean a lot of different things, though. There’s an ENORMOUS difference between archviz, where you import the whole thing as static geometry, and what it sounds like you are trying to do. I’m sure what you’re trying to do is possible, but it may not be something that there’s a simple tutorial for.
It sounds like you don’t understand the physics systems and how to use Unity.
The error you’re getting on the meshes is legit, you should fix properly that instead of just randomly clicking boxes until it goes away. By turning on isKinematic you’ve created an unintended behavior where your objects aren’t affected by gravity. This isn’t a bug, this isn’t related to VR, it’s just something you did because you don’t understand the systems.
You’ll be asking these types of questions endlessly because you didn’t take the time to learn how to use Unity properly - get on that, and these issues will dissolve naturally.
Hi LaneFox, thanks for your reply. You’re correct, i don’t know how to use Unity - i dabble, and rarely. All i’m trying to do here is compare it with another application, so it is just a test really:
Import CAD data and move the parts using the Oculus Rift.
I want to check the structure is correct, how easily and quickly it imports (all good) and how easy it is to get the Rift working and be able to manipulate the model (not going so well).
I understand Unity is a huge application and very powerful with wide-ranging capabilities. I just thought i’d be able to test these small parts - maybe not.
Yeah, it probably won’t be difficult, depending on exactly what you want to do.
Going back to the post that I wrote last week, you could simply write a script to switch the rigidbody’s isKinematic on and off. When the part is attached to the bike, you don’t want it to move or collide at all (except to detect when the player is grabbing it) so isKinematic would work perfectly for that. Maybe use a trigger collider to detect when the player’s trying to grab it.
Then, when you grab the object, that’s when you want to have working physics, so just set isKinematic to false and suddenly it will collide and work with gravity.
Or possibly, you only want physics to kick-in when you drop the item, so switch iskinematic at that point.