Mesh collider problem with two models next to each other - unity3d

As you can check from video link I have a mesh created from two models, for some reason sometimes ball collides with middle part between two models, in the test I've run seen in video I've combine two models in Blender and merged vertices by distance, I've also tested putting two meshes next to each other (just in Unity without exporting to Blender) it was worse. I also set Default Contact Offset very low (2e-05) and collision detection as continuous but nothing worked
Any help is appreciated I also dont want to merge every model in blender so if there is a fix I can use in Unity and put models next to each other without problem it would be awesome
Test video

Do you user Meshcollider or BoxCollider? If you use MeshCollider make sure they are marked as Convex. Always use simple collider if you can.

Related

Unity 2D: physics-based pathfinding package/library

I'm working on a small project where the goal is to defend yourself from mass enemy hordes in a 2d environment. The goal is to have the game be physics based, with enemies pushing against eachother to create a feeling of chaos.
Now I have a setup with enemies, a player and multiple obstacles all with a Rigidbody2D and 2D-colliders (mixed types, including polygon2D collider). Now I want to have the enemies chase the player. The obstacles however are polygon shaped rigidbodies, and thus are able to move.
So I want the "navigation" mesh of some sort to update on the fly, and calculate a navigation path for many entities.
Note: I don't know how many entities yet, but let's say ~100.
The things I tried to far:
Using the built-in NavMesh package from Unity. This package does not properly support the 2D configuration of Unity
Using the NavMeshPlus package. This implements a NavMeshSurface2D component to work with the 2D environment. I got this to work, but the NavMeshAgent component to steer the enemy does not use the force attribute of the rigidbody component, but rather just sets the speed or position of the transform. If someone knows how to use the NavMeshAgent or the NavMesh API in a way to get the target direction/speed via script, that would also be a solution
I tried the A* package. Which also works, but creates a very jagged line as it only can move in 8 directions (up,down,left,right and diagonals). It also cuts the corners of the obstacles, and does not take into account the size of the object (enemy) itself, so it hangs at the corners.
If anyone knows a good package/extension or the location of documentation of the NavMesh part, that would be great!
Thank you in advance.
So I got it to work and will share the solution I took:
Using the NavMeshPlus package, I created a navmesh.
Instead of using a NavMeshAgent, I configured an agent type in the navigation window with the right physical dimensions.
Next I added a script on the enemy to function as a custom NavMeshAgent.
Add a NavMeshSurface2D reference to the script (Serialized)
Using UnityEngine.AI, call NavMesh.CalculatePath(), with the AI.NavMeshQueryFilter. This has 2 components, the agent and area setters. Both of those I get from the NavMeshSurface2D reference.
Now you have the path the agent has to follow!
By the way, I'm also aware this could be done by a custom Agent inheriting the NavMeshAgent class, I'm also looking into that. Time will tell which one will have better performance.

Prefab in Unity and HoloLens falling below the spatial mapping

I'm working in a Unity application with HoloLens, where I place different prefabs across a room and I use TapToPlace to put it on a surface using SpatialMapping. I works great with some fbx models that I had, but then I received some models that I got in .max format, which I converted to FBX using 3DS Mask, they look good, but the exact setup as the other models, whenever I tap them, they are place halfway below the surface.
I've noticed that the working prefabs puts the cursor right at the bottom when in placing mode, while the "broken" ones put the cursor in the middle. Here is an example of how it looks in Unity:
Working:
Not working:
What is that circle there? it looks like the cursor, because everytime that I tap the object, the cursor is placed exactly there for each prefab, but for the ones in the center, half of the model shows below the surface, somehow it looks like it's related; is there a way to move that to the bottom as the working one looks like? if not, is there something that I need to do in 3DS max when exporting these new models to FBX? both models are using box collider, TwoHandManipulatable and TapToPlace.
Thank you, I appreciate the help.
The issue is on the axisof the model -- the pivot point of the model is not at the bottom of the model.
If at all possible it is recommended that you fix the model in your 3D modelling application, If this is not possible, you can fix it in Unity by adding an extra parent transform, more information please see:
https://answers.unity.com/questions/62675/redefine-axis-of-an-object.html
https://answers.unity.com/questions/357698/can-we-change-the-pivot-points-of-any-gameobject.html

Why navmesh can detect all subtilities of my model while meshcollier can't?

I just made a quick terrain in sketchup to test an fps system I made.
The navmesh fits perfectly my model (which is imported in one block) but I made some research and couldn't find a way to hade a clean collider following the model so my Player could navigate normally through it. Isn't there any way to do so?
You need to set your collider to be a concave mesh.
Untick the "Convex" settings on the mesh collider

Collision issue when player moves from one object to another

In unity 5 I am having an issue with certain collisions. I made a basic maze-like game where the player controls a cube across platforms (made from other cubes). In certain areas, two or more of the platforms touch so the player can get to different areas of the level. The problem with my collision happens at these intersections. The player will seem to get stuck for no reason and they would have to back up and get a running start in order to get to the other platform. I went through everything and made sure they are lined up perfectly in the unity editor but nothing seems to fix this.
Any advice would be greatly appreciated .
EDIT: all of my objects are using box colliders
A common (and good) practice is to use a Circle collider on the bottom of your character object in conjunction with a Box collider.
For Example:
While this will likely fix your issue, the source of the problem is probably using many small tiled cubes each with their own colliders. A large amount of tiled objects with colliders most likely cause performance and collision issues.

How do I stop two gameobjects from going through each other on unity3d

I have tried every from unchecking the matrix box , and removing the sphere collider . The problem I am having is the gameobjects wont stop going through each other .I dont know what is going on . I have a pic of what is going on : enter image description here
First of all, don't remove the colliders and make sure they are not set on Is Trigger (that makes the collider penetrable). Also, you are using sphere collider for quite a complex mesh, so I'd recommend using MeshCollider, which would generate it according to the mesh.
Secondly, recheck how you move the objects. If given too much force, it might bash through another collider and not get out of it (imagine that you breaking through a barrier and inside it you cannot get enough speed to break out of it again). That might happen if you use AddForce() and not increasing transform.velocity.
Thirdly, what controls these gameobjects? Player or NavMeshAgent? Because, I think, if they are controlled by AI (NavMeshAgent), they should avoid each other in their paths and shouldn't collide. However, I might be wrong on this one.