Serious Sam Fusion 2017 (beta)

Serious Sam Fusion 2017 (beta)

Not enough ratings
Adding Dynamic Bones to Players and Puppets
By Ryason55
This guide will show you how to add Dynamic Bones to your characters with this mod:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1304802396
   
Award
Favorite
Favorited
Unfavorite
Basic setup
This mod was originally intended to add, uh, breast jiggle physics to models, and as such it's set up to handle this for all models by default. In order for this to work, your model must have "L_Breast" and "R_Breast" bones, which must be parented and oriented the same direction as "L_BreastRoot" and "R_BreastRoot" bones respectively. As long as all these bones exist on the character's model, it should work. If the breast bones aren't oriented the same way as their parent bone, they will be forcibly rotated into that orientation due to how its set up, which probably won't look good in most cases. Note that if your model originally had animations handling the breasts, this will probably screw those up for when the Dynamic Bone mod isn't installed.
Adding additional Dynamic Bones
If you want to further customize the behavior and add more dynamic bones, you'll need to do a bit more. Firstly, your character must have a unique bone prefixed with "Ident_" (so something like "Ident_Example"), and should be located somewhere on the +Y axis (preferably not parented to anything). This is how the script will identify your model. Any additional dynamic bones must be set up similarly to the breast bones from before. If your dynamic bones are already in a straight chain, you shouldn't need an additional root bone for each subsequent one.

From here, you will need to make a script. If you want to add new bones using the default settings, use this as a base:
while worldGlobals.AddNewDynamicBone == nil do Wait(CustomEvent("OnStep")) end worldGlobals.AddNewDynamicBone("Ident_Example","L_BreastRoot","L_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","R_BreastRoot","R_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","NewRootBone","NewDynamicBone")

Note that making a new configuration like this won't have the Breast bones by default, which is why they're included in the script. You can exclude them if they aren't needed.
Further customization
Here's an example of how to tweak the settings of each bone, shown using the current default values:
while worldGlobals.AddNewDynamicBone == nil do Wait(CustomEvent("OnStep")) end local Damping = 0.1 local Elasticity = 0.5 local VelocityInfluence = 0.5 local VelocityCap = 4 local Inert = 0.7 local MaxDistance = 30 local AutoAdjustMult = 1 local BoneSettings = {Damping,Elasticity,VelocityInfluence,VelocityCap,Inert,MaxDistance,AutoAdjustMult} local Heading = 0 local Pitch = 0 local Banking = 0 local BoneAngles = {Heading,Pitch,Banking} local HeadingLimitLower = -1 local HeadingLimitUpper = -1 local PitchLimitLower = -1 local PitchLimitUpper = -1 local BoneAngleLimits = {HeadingLimitLower,HeadingLimitUpper,PitchLimitLower,PitchLimitUpper} worldGlobals.AddNewDynamicBone("Ident_Example","L_BreastRoot","L_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","R_BreastRoot","R_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","NewRootBone","NewDynamicBone",BoneSettings,BoneAngles,BoneAngleLimits)

Which can be shortened to:
while worldGlobals.AddNewDynamicBone == nil do Wait(CustomEvent("OnStep")) end local BoneSettings = {0.1,0.5,0.5,4,0.7,30,1} local BoneAngles = {0,0,0} local BoneAngleLimits = {-1,-1,-1,-1} worldGlobals.AddNewDynamicBone("Ident_Example","L_BreastRoot","L_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","R_BreastRoot","R_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","NewRootBone","NewDynamicBone",BoneSettings,BoneAngles,BoneAngleLimits)

Or even:
while worldGlobals.AddNewDynamicBone == nil do Wait(CustomEvent("OnStep")) end worldGlobals.AddNewDynamicBone("Ident_Example","L_BreastRoot","L_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","R_BreastRoot","R_Breast") worldGlobals.AddNewDynamicBone("Ident_Example","NewRootBone","NewDynamicBone",{0.1,0.5,0.5,4,0.7,30,1},{0,0,0},{-1,-1,-1,-1})

The parameters are (roughly) as follows:
Damping: Adjusts how fast the bone will come to a stop
Elasticity: Adjusts how much the bone is pulled back into its default position. 1 is no Elasticity, and 0 is "basically won't move"
VelocityInfluence: A multiplier for how much overall velocity affects the bones, including things like character rotation.
VelocityCap: Caps the velocity applied to the bone.
Inert: A multiplier for how much the character's velocity is ignored when calculating velocity. A value of 1 would mean that the bone is only affected by animations and character rotation. For players, this is automatically adjusted depending on the game.
MaxDistance: The maximum distance from the local player where that dynamic bone will be calculated. A setting of 0 means the dynamic bone will only calculate for the local player.
AutoAdjustMult: a multiplier for how much the Inert is adjusted between games for players, ranging from 0 to 1. 1 is normal adjustment behavior, while 0 is no adjustment. Use this if the bones aren't jiggling the way you want in SSHD and the Versus modes.
Heading, Pitch, Banking: Affects the default rotation of the bone. Note that bones cannot be rotate more than 90 degress from its parent bone, so each angle is capped to 45 to give room for jiggling.
HeadingLimitLower, HeadingLimitUpper, PitchLimitLower, PitchLimitUpper: Sets rough limits for how much the bones will be able to rotate. Angles you want to limit should be set to a positive value (0 to 90), and angles you don't want to limit should be -1. Note that this is affected by Elasticity, and you should give about 10 degrees of space past the limit (depending on elasticity).

If you don't need to change a value from default, you can set it to nil. Do note that I've implemented a hard limit of 40 dynamic bones, since performance takes a hit if you have too many characters using too many dynamic bones. This is mainly so you can't do rediculous things, like full dresses.
Saving the script
Once you have your script ready, it needs to be saved to 3 different locations, since it'll need to run in 3 different game types. The filename should be something like "DynamicBoneSettings_[ModelNameHere].lua", so that you can tell what it is, and so it'll be loaded right after the handler script itself. Now, the simplest thing you can do is save a copy of the script to each of these locations:
Content/SeriousSam3/Scripts/CustomWorldScripts/
Content/SeriousSamHD/Scripts/CustomWorldScripts/
Content/SeriousSamHD_TSE/Scripts/CustomWorldScripts/


The only problem with this is that if you need to change something, you'll have to change it for all 3 scripts. If you just want to update the one script, save the main script in Content/Shared/Scripts/, and have the scripts in the 3 game folders contain this:
dofile("Content/Shared/Scripts/DynamicBoneSettings_[ModelNameHere].lua")

If any additional gametitles are added (whether officially or through mods), the script will also have to be included in the folder for that gametitle as well. In the future, I hope there's a way to just save a file to a single folder and be done with it, but it can't really be done at the moment. Also, if you're planning on adding dynamic bones to multiple characters that you're going to include in a pack, its recommended that you include all of their configurations in the same script.

Currently supported custom gametitles include:
Z_7SmokeTennis2017_Blue
Z_7SmokeTennis2017_Red
Z_SeriousBoxSolid
Z_SeriousHorsam
Conclusion
At this point, the Dynamic Bones should be applied on the model. Test them out ingame and see if they function to your liking. If they're stuck at odd angles, it's probably because they aren't oriented the same way as the parent bone. If they don't move how you'd like, adjust the parameters in the script as you deem necessary.

If you need an example of how things are set up, see my Witch-Bride player models which make extensive use of it:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1304806308
2 Comments
Rockittt 16 Oct, 2018 @ 4:55am 
Been thinking of adapting my character model with Dynamic bones, done it already in Unity, Looks like a right faffon doing it in SED is there any way to test the settings in editor without having to go in game to test everything? (Its been a while since ive used SED)
Saviour 20 Feb, 2018 @ 2:54pm 
how bout you translate this to english for people who don't understand