Question How to make mesh colision for your custom model assets?

zqwvc1419

Member
Messages
83
Reactions
33
Points
18
Now you should know how to create a custom asset element, and probably how to properly create an assetbundle file. Using Unity Editor 2018.1.9f2 version, install the plug-in tool: Unity Bundle Browser. Drag the prefab file into the box and package an assetbundle file.

But: How do you set up collision bodies for your custom models?
When you create the model and paint it, but the model initially has no collision volume, any object can pass through it. So you need to add a collider to the object. A wall that nothing but a camera can pass through. Moreover, the collision body is very detailed like the 3D object. However, after we model the object, do we have to model the collision body again? Obviously this is wrong.

Do you know the role of .shape files? Can blender generate this file?

In addition: As you know, the characters in VAM change all the time and make various actions, so the collision bodies of the characters also change all the time. (No matter what action the character makes, you can't let objects pass through it, right! Unless the collision button is turned off.) Do you know what the principle is? Why can the character's collision body change with the character's movements and appearance?
 
屏幕截图 2023-12-17 083748.png
屏幕截图 2023-12-17 083708.png


See it? The green part in the model is the collision body of the model. This collision body is delicate and complex, so complicated that it seems like the object has been remodeled.

The green part is the important discussion about this issue.
 
Upvote 0
I'm not an expert in Unity, but I'm assuming you are asking how to make mesh colliders of individual items inside this "shape" object of yours instead of adding it to everything? I don't have an exact answer to this but an alternative you can use is "primitive colliders" i.e. "box colliders", "capsule colliders", "sphere colliders".

You can add, for example a "box collider" as many times as you want, drag it where you need, and only on those objects that you wish to create a collision. I shall add that using primitive colliders like these are far better for performance, especially if you are going to be using it for VR where every bit of performance matters.

I've only used unity here and there, but from what I know you can add a cube into your scene, then position/scale it however you want and then simply remove the "mesh render" giving you a box collider that you can easily position however you want. You can stack these colliders into the shapes of the object, just make sure you parent everything under the asset, you will benefit from having colliders that aren't too performance intensive and its a good alternative to using just mesh colliders.
 
Upvote 0
I'm not an expert in Unity, but I'm assuming you are asking how to make mesh colliders of individual items inside this "shape" object of yours instead of adding it to everything? I don't have an exact answer to this but an alternative you can use is "primitive colliders" i.e. "box colliders", "capsule colliders", "sphere colliders".

You can add, for example a "box collider" as many times as you want, drag it where you need, and only on those objects that you wish to create a collision. I shall add that using primitive colliders like these are far better for performance, especially if you are going to be using it for VR where every bit of performance matters.

I've only used unity here and there, but from what I know you can add a cube into your scene, then position/scale it however you want and then simply remove the "mesh render" giving you a box collider that you can easily position however you want. You can stack these colliders into the shapes of the object, just make sure you parent everything under the asset, you will benefit from having colliders that aren't too performance intensive and its a good alternative to using just mesh colliders.


Thank you for your answer. My question is how to set up a collider for an irregular, hollow object. Currently, I am talking about a building model. Building models do not move, so their collider shape does not change. However, if I use a box colider to wrap the entire building, you will not be able to enter the interior of the building in the game. Box colider should also be uncommon, as it is only suitable for the simplest cubes. I think that the work of setting up a collider for an object is not done in Unity, but in Blender. Blender will generate a .shape file, and then you can assemble it to the model in Unity. You know, buildings are not moving, and their colliders are always the same. But characters are not the same. They are moving all the time, and their colliders are also changing all the time. So, do you know how to set up a dynamic collider for a character or monster model?
 
Upvote 0
Colliders can't deform, but you can make them follow the body by making each being a child of the correct bone (you would need to make a collider for each moving part).
You could make the collider appear to deform by rebuilding it every frame, however this would have a big effect on the frame rate.
Maybe you would be interested in this: https://assetstore.unity.com/packages/tools/physics/rascal-skinned-mesh-collider-134833 (not sure if this would work with your model or with the unity version used to export models to vam)
 
Last edited:
Upvote 0
if I use a box colider to wrap the entire building, you will not be able to enter the interior of the building

Correct. For example in this situation, if you have a wall with a door, you can use two box colliders on that single wall, but arrange the two box colliders about half way each but don't let it cover the door that is in the middle. You can still enter and exit from the door area since that doesn't have a collider but the rest of the wall will have those colliders. So you can set up primitive colliders and change their shapes to try and "match" the object you want collision.

For simple objects like walls or floors its simple to drag box colliders and shape/size/position them to match the object, for complex objects then you would use mesh colliders or you could just build on the primitive colliders and reach "close enough" to what your original shape was.

Regarding your question about shape, you can use blender and perhaps you could separate the objects individually and then export them into unity as separate objects and combine them into one scene, I assume this would allow you to add mesh colliders on the objects you have separated while leaving other objects untouched.

Character models, well not to familiar with that but you would need a "rigged character". If you don't have a rigged character, you would need to add a character rig in something like Blender or Maya. Unity has something that can automatically add collisions/physics to character-like objects i think its called "ragdoll" generator or something like that. Basically for characters it comes down to rigidbody physics and using custom/character joints with some kind of primitive collider. Unfortunately I've never worked with it but that's just the basics from what I know
 
Upvote 0
Back
Top Bottom