Unity Ideas for character skin collision detection (rigged mesh)

ttrspamm

New Member
May 19, 2023
5
1
I'm currently prototyping an idea I have for a touch simulator game in Unity and I'd like to create a robust system, which is able to accurately detect where the mesh has been touched.
The point is to stop your hand/finger or anything else poking through the skin. The game also needs to know where the body has been touched, so the character reaction can be different if you touch a shoulder compared to a buttocks. I also want it to be precise, so the game can differentiate between a palm or the back of the hand for example.
Finally on a related note I would like to be able to show if a body part like the butt has been spanked by projecting a reddish tint at the spot. Ideally it would be even possible to just paint over the skin with a marker.

Since the character is a rigged mesh that can deform when moving their joints, it's not as simple as slapping on a mesh collider. Those only seem to work for static objects.

Currently I'm able to achieve most of my requirements (minus the painting part), by creating smaller separate skin segments that are fitted over the skin mesh and parented to appropriate bones. At the joints I used capsules, to avoid holes in case a limb is being bent. Then I put a mesh collider over each of those skin segments, and a script that helps with the logic if a mesh segment has been hit. Basically I encased the character in an airtight invisible suit of segmented armor.

This approach actually works fairly well, but there are a couple issues. Firstly I'm unable to accurately place colliders at joints, which means that touching a joint will result in the finger floating over the mesh or sinking into it. This sinking/floating actually happens on other parts of the mesh as well which is the result of the collider meshes not exactly conforming to the skin mesh, but it's not noticeable unless you zoom really far in. While I'm able to come up with workarounds which would involve adding additional colliders and conditionally disabling them depending on the orientation of the limb, there's a much bigger issue which is making me look for potential alternatives:

This approach is not scalable at all. Any changes to the characters physique also results in having to modify colliders. Not only does this make the support of multiple body types impractical, since I'd have to manually recreate full new collider set for each one, which is a very time consuming process, I'd also need to tinker with it if I decide I want to change something about the currently used character, like increasing the breast size or adding some body weight, for example.

For most other types of games, developers would probably just use a couple of capsule colliders for each limb as such a precise collision detection usually isn't that important. As a result I couldn't find much info on the subject. This game would however be played form a more intimate perspective. Inaccuracies would be much more noticeable. I'm hoping someone here might have some technical insight on the subject.

And for the slap markings I mentioned earlier, currently I'm able to spawn a decal projector at the point that was hit by a raycast and parent it to the appropriate collider. These again work for the most part, but they tend to "float" across the skin, since the decal projector is anchored to a "static" object, while the skin is able to stretch and twist. I'm not really sure how to improve this, or how I'd even attempt marker paint support. But that's not actually a priority feature.

I'm hoping there's a more sophisticated solution to my problem. I would hope that with the rise ov VR games someone figured out a good workflow for this. And since this mostly applies to adult games, I assume this is probably the best place to ask.

Any help or suggestions regarding this would be appreciated. Even pointing me at some paid tools/assets or solutions used in other engines would be helpful.
 

robotraptorbudda

New Member
Jul 19, 2023
13
84
This sounds like you're basically trying to put a mesh collider that updates every frame to a skinned mesh renderer...which, as far as I know, is an extremely expensive operation that you definitely should not do, at least not with Unity.
 
  • Like
Reactions: PsyTurtle