Unity Colliders

Ghostwalden

Well-known member
Messages
203
Reactions
1,069
Points
93
Hi there

Mostly when i use Generate Colliders, it does its job
1713609907909.png


But on some Objects, it doesn't work.

Therefore i tried the Mesh Collider, but the collider does not have the right size for the model.
As you can see in the Picture, it is much smaller and hangs around in the Air.
1713610059003.png


This one i used, was included in the Object, when i unfold the Object, i can draw this to the mesh collider.
1713610197470.png


Is there a way, to change the size of a mesh collider and change position?
 
Hi there

I could solve the problem.
I made an empty object, added the colliders to the empty object, then scaled and positioned the empty object and added
it to the Object.
 
That's "hacky" at best : )

You should not have to do this. Adding a mesh collider to the target mesh renderer should immediately be scaled accordingly, unless you have added the mesh collider at the wrong place.

Can you show where is your collider and where is your mesh renderer?
 
Hi hazmhox, thanks for your reply.

I draged the Object to the scene.
Then clicked here on the object.
1713946291790.png


Set Position to 0,0,0
Added a mesh collider and draged in the Mesh.
1713946341756.png


Thats the Mesh i used for this example
1713946448126.png


1713946491353.png


Then it looks like this in the scene
1713946547759.png


I usually just click the Object here
1713946647952.png


Then activate Generate Colliders and apply
1713946708409.png


Mostly this works for colliders, but in this case it doesn't.
I have no idea, why this works on some objects and on others it doesn't
and i have to use the mesh collider.
 
The mesh collider component has to ALWAYS be on the same object as the one with the mesh renderer.

If you have dozens of complex sub objects, you will need to add the mesh collider on EVERY important sub object with a mesh. It's important to choose what and not to add collisions on, and if you could replace a mesh collider by a simpler collision like box or capsule.
 
Thanks alot hazmhox

Yes now the collider fits in its size, when i put it on the corresponding object with the mesh renderer.

There's another thing about colliders in Unity, i don't really understand. Maybe you can help me with these as well ;)
When i click on the Object under Assets, i can then then in the Inspector Windows select Generate Colliders and Apply.
1714033890021.png


On some Objects this creates Colliders, that works in VAM, but on others nothing happens.
If it works, it is the easiest way to add colliders, whithout to have to add a single mesh collider
to every object.

So, but what i don't understand about this one is.

- What is the difference between this option and adding colliders manually?
(Guess this adds just all the mesh colliders at once automatically?)

- Why does this sometimes work, and sometimes it doesn't?
I had objects it worked, and when i for example imported the same object again
it didn't work anymore.
Or on this Detention Hall Object, Generate Colliders doesn't work at all.

Also do the green collider grid doesn't show up, when de object is selected, if mesh colliders have been added with this option.
When i ad a mesh collider manually and select the object, the grid shows up.
I don't know why this is, because the Mesh Collider is there, whether added manually or by this option.
 
Never used the generate colliders, it's glitchy af. And collision are way too complicated (and very context sensitive) so, I've never used that. I would suggest to always author your collisions manually : )

Also do the green collider grid doesn't show up, when de object is selected, if mesh colliders have been added with this option.
When i ad a mesh collider manually and select the object, the grid shows up.
I don't know why this is, because the Mesh Collider is there, whether added manually or by this option.

Because you haven't understood mesh colliders lol :p

Mesh colliders are "unscalable" collisions. The are tied to the size of the gameobject itself. So... if you add them on an empty object, they will show the collision wireframe because you have no model ( mesh renderer ) connected to it.

If you have a mesh renderer, the wireframe will not show if the mesh renderer is using the same mesh as the mesh collider.
Simply because the mesh collider being always the same size as the gameobject itself, you actually SEE the mesh with the mesh renderer... so it's kind of useless to show the wireframe because it is implied that it is the exact same thing ^^
If you have a different mesh in the mesh renderer and in the mesh collider, the collision wireframe will show up.
 
Hi hazmhox

Thanks for your reply.
Yes, you're absolutely right, i haven't understood mesh colliders yet, guilty ;)

Makes absolutely sense, what you said.
Now i wanted to try it out and what did i get? some big ??? :LOL:

Ok, i opened the Inspector from my Plunger, where the Skinned Mesh Renderer is.
Then i added a Mesh Collider with the same mesh as it is in the Mesh Renderer.
1714053227886.png


But the Wireframe from the Mesh Collider still shows up :unsure:
Or is it just invisible with the Mesh Renderer but not with the Skinned Mesh Renderer?
1714053458748.png
 
Umh weird, that may be due to the skinned mesh renderer.

Skinned mesh renderers are different. A mesh collider is kind of "proposterous", because mesh colliders cannot be skinned : )

If you have an actual skinned mesh, with a plunger that is kind of wobly or something like that, you need to do a proper capsule/standard collision or the collision will remain fixed.
 
Yes, then the skinned mesh renderer may just behave different in this case.

I don't have any knowlege about mesh renderer or skinned mesh renderer,
so i dont know, what they should do and what not :unsure:
I'm just happy, when my collision works :)

With wobly you mean in vam, when physics is activated?
 
Wobly means something that is a bit "springy". You can set that up through hinges for instance.

Since it seems you don't know the difference, it's recommended that you remove the skinned mesh and swap to a normal mesh renderer. Skinned mesh is more expensive. If you don't use it, it's not necessary.

Skinned mesh = character. It deforms through weights on the "skin" (or surface) of the model when moving the bones.
Mesh renderer = static object. It simply is rendering... that's all (no bones).
 
Ah, now i understand.
The Plunger was originally an animated plunger, that deformed when he hit the ground.
Therefore he came along with a skinned mesh renderer.

Thanks, now i know what a skinned mesh renderer and a mesh renderer is for.
 
Back
Top Bottom