Hey ive got a 3d character in my unity project, he got an armature with bones. I want to be able to select them separately, with Raycast for example.
Ive got already a Raycast script, that select and unselect the whole gameobject but for my purpose i need to select each body part.
I saw many tutorials with creating spheres or cubes and place them on the bones but i want to use my own 3d object meshes for that because of the detail aspect.
Well, you can create sphere and cubes and put them on the bones, but don’t show their renderers. That’s basically the definition of a “ragdoll”. You can do it manually, or just use Unity’s Ragdoll Wizard to place them for you. The idea is that your model will be wrapped with small colliders, but the colliders are invisible. The raycast will still hit them, though. Here you can see a model with a bunch of invisible colldiers for each of the limbs. That approach should work for you.
Thx for the reply, but like i said i already know this workaround and thats not fit my purpose. I need to hover pretty accurate each body parts and i also need to show the renderers because thats the point in this case, to know where you can hover to select the body parts
I’m not sure you’re going to have a lot of success with that. It sounds like you want to separate every piece of your model into distinct parts, and have a mesh collider on every piece, so that for any given triangle in your model, you conclusively say which part of the body that is. That’s possible, but it could be really bad performance. This would involve making sure you separate all the pieces in your 3D modelling software, then add a MeshFilter and MeshCollider to each of those pieces in Unity. The main issue comes in trying to keep the colliders sync’d up with the model as the model moves/animations. I’m not sure how it’s done, but I believe you need to rebuild/refresh the mesh filter every frame. That’s expensive, as are mesh colliders in the first place.
Anyway, I don’t think I’d pursue that, personally, unless maybe if the model is completely static and will never move/walk/animate. I’d also be surprised if a careful placement of capsule/box colliders (the standard approach) wouldn’t be sufficient for most purposes. Why exactly does this need to be so precise for your game? What are you doing that needs to be down to the pixel accurate?
Thats actually one way to workaround my purpose, i didnt thought about. I am not aware of every possibility of unity thats why i am asking here for different opinions and i think il pursue the closest one.
My goal is not to collide this character or interact with other object, this is just a body part selection for informative purposes. I would also like to animate the character, so i think ive got to check how accurate i can get with the capsule/box colliders.