- Home /
Mismatched collisions between imported .fbx models and other generic objects
There is actually the problem: OnEnterCollision event has been rised not in time then the actual collision happens (at least visually).
I'll explain the way how I'm doing these stuffs, please correct because I'm definitely doing something wrong (don't have any successful background behind with this).
Creating rigid model in Blender (all meshes are parented to the armature it is connected to).
Parenting the armature by itself to the empty object (to prevent strangle angles effects in Unity after importing the model)
Deleting everything from blender scene (lightnings, camera .. ) except armature and it's child.
Exporting model as .fbx scaled as 0.01 (to make it's more close to desired size in Unity by setting scale to 1)
Dragging the resulted .fbx into my Unity models asset folder.
My model is now getting structure like this:
\ MyModel (Empty Object) \\ Mesh objects (with Transform component only) \\\ Meshes itself (often separated into pieces for models which were imported into Blender as .stl which by itself were pre converted from .STEP format before). \\ Armature \\\ All bones parented one to the previous one + 1 additional end bone at the end
Dragging the resulted MyModel (prefab) to Unity scene.
Attaching box collider and rigidbody components to the bone which mesh I'm going to collide with (Doing this regarding the bone because the mesh object by itself not following it's meshes and appropriate bones ...).
Create another object on Unity scene also with box collider and rigid body on it, setting its tag to "MyTag"
Attaching script to the bone similar to this one:
void OnCollisionEnter(Collision collision) { if(collision.gameObject.tag == "MyTag") { //Do stufff } }
in the same script I'm tweaking it's localRotation for bone in Update to smoothly go closer to the "MyTag" object
Other bone localRotations are also tweaked by its own scripts attached to each of these bones
Starting the Scene
Observing both box colliders on scene and see that the collision enter event rises a little bit earlier than the actual collision is happen ( feel like there is something else invisible else between these two box colliders which triggers the collision earlier).
Okay.. dirty but pushing a collider on bone to the opposite side from the object it should collide with for this invisible amount of space.
Result: awful feeling that this strange thing is happening + if the whole scene will be scaled this invisible gap will become bigger and smaller in the opposite way for scaling (the bigger gap for smaller scalling).
I'll very appreciate any improvement in my dirty way of doing described things and of course i would like to know what is happening with these collisions and how to handle this in a proper way.
Got a pluralsight access so if anyone know a handy course for the things I described and doing wrong, you may also offer it to me.
Please try to help me to sort out with these stuff here.