Unity 4 Character Mesh Collider not aligned - character falls through. Image attached inc source unity asset link - character

Hello Peeps (first post yay).
I have just started to learn about unity and still going through various tutorials and learning the interface along with C#.
I am running Unity 4 and downloaded a free asset from the Unity store:
https://www.assetstore.unity3d.com/#/content/3174
The Problem.
I created a Plane in Unity.
Went to the Character and created colliders and imported it as a humanoid.
Then added a rigid body = The character fell through the plane
I then added a Mesh collider and attached the mesh for the character to the collider. The mesh does NOT align correctly to the character = the character fell through the plane.
I then tried box and capsule colliders and they worked fine. Attached these and the character would not fall through.
I then tried a character controller = Character did not fall through.
I want to have an accurate mesh for this test character so when an enemy hits him, there is an actual hit.
I have tried several other free characters from the store and they all have the same problem. Can someone please tell me how I can fix this? It seems I just either doing something completely wrong, missing a step or just plain lost.
Link below to image of the issue taken:

Using a mesh collider on a skinned, animated character is a wrong approach. Mesh colliders are generally used for environment geometry and rigid objects. This is all due to the amount of work it is needed for the Unity engine to accurately calculate the shape of the mesh collider, based on the provided mesh. More triangles means more work, and for the reasonably complex low poly character mesh of 10k to 30k triangles it is clear that the fps would most definitely drop to an unplayable level.
For our game we are using all primitive colliders, distributed on the adequate bone game objects. So, head bone has a sphere collider, spine has a box collider (for lungs), forearm has a capsule collider etc. That way,with a little bit of scripting, you can detect a hit and know exactly what part of body is damaged.

If your collider doesn't exactly match your mesh, then it's likely that you have the mesh applied to the wrong part of the object.
Try applying the Mesh Collider to the mesh, instead of the complete object.

You have a pretty complex character mesh, so using mesh collider probably isn't the best way to go. In many cases, character controller or capsule collider works fine; otherwise, you can just use compound collider and create a box or a sphere around various body parts of the character.

This once happened to me. The mistake i made was, i applied the mesh collider after i did some rotation and scaling. So i added the mesh collider as soon as i imported the model. And then it should be alright when you scale/edit the model. Also check with right/left handed co-ordinate system with unity and 3D MAX/Maya.

Related

Unity Character Controller

Have Mesh Colliders on everything except the Solider being a child of the Game Object renamed Player.
The Player has a Character Contoller surrounding the child or blue-colored soldier. In Game Play, he falls halfway through the road and gets stuck in Unity. Is there a fix for this????
I noticed the Unity forum had not answered a similar question about it since 2019.
Colliders
Make sure that the actual model / mesh of your character has a mesh collider applied to it and that the convex box is checked. Next make sure that your ground / whatever your character lands on has a collider attached to it whether this collider is of type mesh, box or really any collider it shouldn't matter but I'd recommend trying a cube with a box collider first. Also make sure that all of your mesh colliders actually have a mesh applied to them.
For your character controller double check that the size of it matches your characters model in both width and height. Apply the actual Character Controller to the Parent game object in your case named Player and apply the mesh collider to your actual character.
Some Images of how it should look when correctly set up
How the parent "Player" should be set up simply
How the actual character should be set up simply
How your ground should be set up simply

How to handle Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5?

I'm using Unity 2019.4.2f1 personal
I'm getting exception :
Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5.
If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path
I have a parent GameObject with some components including a Rigidbody :
Then there are some children of this parent and somewhere inside there is this child name NAVI and all the polySurface34 children of NAVI have a Mesh Collider with Convex unchecked option.
I know that if I uncheck and disable the Mesh Collider on all the polySurface34 objects it will make the error exception to be gone but I'm not sure if this is the right solution if at all.
As the issue says, you can't use non-convex mesh colliders with non-kinematic rigidbodies anymore.
AFAIK this can be solved in at least these 2 ways:
Use a convex mesh collider, which will be less accurate but actually work
Use multiple primitive colliders (this is usually the best solution for player/humanoids) as it's efficient and you can place the colliders on the rig itself and they will move with your animations
Attached is a visualization of the hitboxes of one of the characters from Overwatch.
As you can see, they use multiple sphere & capsule colliders to approximate the character (notice that it's also slightly larger than the actual model, this is a game design choice to make hitting a character easier/harder).
Also note that the red capsule in the middle is used to very efficiently identify critical headshots; and this is another advantage of using multiple colliders vs. a mesh collider for characters

Unity3D Collider Passing Through Other Colliders

The Problem: Mesh colliders on some rigidbody objects are passing through colliders on other objects.
Things I have tried:
With the assumption A is a GameObject with a RigidBody attached and B is a normal GameObject with a collider.
Give A a convex mesh collider
Give A a non-convex mesh collider
Give B a convex mesh collider
Give B a non-convex mesh collider
give B a box collider
give B a convex mesh and box collider
give B a non-convex mesh and box collider
Adjusting the weight of the rigidbody
I have tried all of these in all combinations of A and B.
In addition,
Colliders are not marked as triggers
All objects are on the default layer (0)
Checking isKinematic; doing this seemed to make gravity stop affecting the object, so I have left it as false.
Constraints: I want A to use a mesh collider since most of the objects involved are moderately complex, and fitting other colliders to them would take a while.
Weird Behaviour: I have some objects with both rigidbody and convex mesh collider where the collision is working fine with a non-convex mesh collider. This is inconsistent with other gameobjects. The objects have all of the same settings.
I am using unity version 2019.3.11f1 if that is relevant.
The object being used are from this package. Specifically, the filing cabinet with rigidbodies on the drawers works fine. The desk, office chair, pen, and open laptop all fall through the "floor" (a cube with all of the above colliders tested on it).
Do you have 'isKinematic' checked on the objects with rigidbodies that are going through other colliders? If so uncheck it so that external forces affect it.
edit you also need to click convex on the mesh colliders if they are colliding with other mesh colliders, Convex Mesh Colliders are limited to 255 triangles, are the objects that are not passing through have more than 255 triangles in geometry?
I am Assuming you have set your Collision Detection to Discrete In your gameObject's RigidBody, if so, please make sure to select Collision Detection to Continuous In your gameObject's RigidBody.
Reason Why this is not working
You are trying to use collision that has (speed > your Computer's frame speed) so, the frame is not catching the collider properly some time catches and some time fails to catch.
You are moving your GameObjects with tranform.translate or position etc. If so then make sure to use Rigidbody Related function for Positioning, rotating.
Solution Image For First Problem
I'm assuming
-you game object which contain the mesh component is very small ( bellow 0.7 size(x,y,z) so the game engine is little difficult to detect it)
and also
for the colliding objects at-least one rigid-body component must be attach to one object
This seems to be a common big problem, and I have been struggling with the same issue for days, and have finally fixed it, so am feeling like I should highlight one important thing:
move Rigidbody via MovePosition, not via just changing its position field directly, nor via changing position of GameObject holding it.
Changing position via "wrong" ways will "teleport" your rigidbody, physics won't fully work on it in that case.

Blender import in Unity, how to generate correct mesh collider?

How to get/generate a proper mesh collider in Unity using a model exported from Blender (.obj/.fbx)?
This is my second day using Blender and I'm hitting a roadblock. I've tried fiddling with the Rigid Body Collisions, i.e., setting "Shape" to Convex Hull and "Source" to Final/Deformed (Blender docs specify that these two settings capture modifiers), I've tried "Generate Colliders" inside Unity and the mesh collider always comes out as above. A box.
How to assign mesh collider to the exact mesh? I started with a circle and used a boolean modifier to create the cutout. Desire is to have the mesh collider around the mesh exactly, meaning no collider on the cutout. How to do this?
Make sure you have a Mesh Collider component on your object with the correct mesh set. Watch out for the convex parameter for flat objects, as it can sometimes fail and give you a box collider instead.
Edit:
I just noticed you said you were using a RigidBody, which means you need to have Convex set. A solution to this is to make a second mesh in Blender with a third dimension to it, then set the flat one on the Mesh Filter and the one with thickness to the Mesh Collider.
In importing a .obj or a .fbx, select the asset. make sure you have generate colliders selected.
Here I have imported an FBX into unity, but there are no colliders.
Sellect the asset, and turn on generate colliders if you want a collider around the mesh:

Unreal Engine 4 - Collider component sweep issue

I have a 2D environment where an object falls (a trap) and a box collider component is moved with a timeline to follow the movement with SetRelativeLocation.
Since the trap is near a wall if I leave the Sweep option unchecked in some cases the character will stuck mid air between the trap and the wall.
Sweep off
If I turn on Sweep this will not happen and the character is pushed to ground correctly but since the collider "slows down" for some frames it seems to be in the middle of the sprite.
Sweep on
Teleport option seems to have no effect on this behaviour.
Is there any way to have the sweep effect with the collider keeping his velocity and keeping the structure as it is with the collider moved by a timeline?
I feel like I'm missing something really simple but I'm losing my head on this.
Thanks!
Since it's 2D, have you tried blocking the input when your character collides? I would add a simple collider in front of your character and when it is overlapped, I'd limit the input in the direction your character goes, ie.:
Character collides right
MoveRight(float Scale): Clamp Scale to (-1.f, 0.f); AddMovementInput(...
Hope it helps!