nicoco007 / BeatSaberCustomAvatars

Beat Saber mod that allows the use of custom player avatars for in-game body presence.
GNU Lesser General Public License v3.0
258 stars 41 forks source link

Support for constraints (like rotation constraints) #130

Closed Erinaaaaaaa closed 1 year ago

Erinaaaaaaa commented 2 years ago

Is your feature request related to a problem? Please describe. I used to use dynamic bones to have the model's skirt follow the legs as the player crouches but sometimes the leg ends up clipping through the skirt (due to the way the armature is designed or otherwise)

Describe the solution you'd like Unity Constraints would be a nice way to implement this kind of model feature

Describe alternatives you've considered Dynamic bones, as explained above

Noneatme commented 2 years ago

Yes please, I cannot use my entire avatar because of this. I am binding attachments to a tail which is a dynamic bone, it doesn't follow the dynamic bone because constraints don't work.

nicoco007 commented 2 years ago

Just to clarify, you're talking about Unity's built-in constraints (position/rotation/scale/parent), right? I'm currently using the Parent Constraint on one of my avatars and it seems to be working fine. Custom Avatars doesn't touch them at all so they should in theory just work – the only reason I can think of that would cause them to not work is an internal incompatibility between older versions of Unity and Beat Saber's current version (2019.4.28). If that's the case, there's nothing I can do – you just have to update your project. The supplied avatars project is on 2019.3.15 due to compatibility issues with Modelsaber so that might be the problem. If you're running anything older than that, definitely try to update to 2019.3.15. If you're already on that version, could you try making a copy of your project, opening it with 2019.4.28, and exporting your avatar?

Erinaaaaaaa commented 2 years ago

I was indeed using Unity's built-in Rotation Constraints. Though, now that you mention it, the Unity version used might be a problem: I just noticed the project was last worked on in 2019.4.31, which is beyond Beat Saber's current Unity version. I guess it's fair to assume that is going to interfere.

Should I try using 2019.3.15 and/or 2019.4.28? (Which of the two?)

nicoco007 commented 2 years ago

2019.3.15 if you plan on publishing to Modelsaber, 2019.4.28 otherwise.

nicoco007 commented 2 years ago

Just checking in – did you manage to fix the problem or are you still having trouble?

RedHaze commented 2 years ago

Hi @nicoco007 , I was having an issue where rotation constraints for twist bones were not working in BeatSaber for my avatar. I installed 2019.4.28 and re-exported the avatar but unfortunately, the twist bones appear to still not work correctly. Should I be using the TwistRelaxer, and if so, is there a guide for this script? FWIW, I use the same rotation constraint properties in VRChat and they work great. Let me know if any additional info is needed and I'd be happy to provide :D.

nicoco007 commented 2 years ago

Unfortunately I was mostly wrong with my answer above. Constraints only work when they affect a bone that isn't part of the set of bones that the IK affects and even then I believe they're actually updating a frame late (I was using a parent constraint on a shoulder decoration so it looked like it worked). This seems to be a known issue and I don't believe there's anything I can do about it. VRChat used to use FinalIK as well but I'm guessing they either modified it or use something else now to make them work.

You should be able to use the TwistRelaxer component in a similar fashion to how you use the rotation constraint. The tooltips on each of the settings somewhat explain the process; basically, add the component to the forearm bone, set "Parent" to the elbow bone, and "Child" to the hand bone. You can technically just add the component but if the bone structure isn't super straightforward it might get confused while trying to detect the parent and child.