Skip to content

Commit

Permalink
Physicanim [v1.1.0]
Browse files Browse the repository at this point in the history
~* BUILD ACTIVE RAGDOLLS IN ONE CLICK
~* ANIMATE RAGDOLLS
  • Loading branch information
TildeAsterisk committed Sep 18, 2022
1 parent be7147b commit 33e30ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Scripts/Editor/ActiveRagdollBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,15 @@ GameObject InitialiseARagObjs(){
anim = PhysicsBodyTF.GetComponentInChildren<Animator>();
}
if (anim != null){ DestroyImmediate(anim); }
Debug.Log("Animator on PhysicsBody has been destroyed.");
//Debug.Log("Animator on PhysicsBody has been destroyed.");

//If StaticAnimator doesn't have an animator component, add one.
anim = staticAnimator.GetComponent<Animator>();
if(anim == null){
anim = staticAnimator.GetComponentInChildren<Animator>();
}
if (anim == null){ anim = staticAnimator.AddComponent<Animator>(); }
Debug.Log("Animator on Static Animator exists."+ anim.name);
//Debug.Log("Animator on Static Animator exists."+ anim.name);
//Set animator variables
anim.cullingMode = AnimatorCullingMode.AlwaysAnimate;
anim.applyRootMotion = false;
Expand Down
13 changes: 8 additions & 5 deletions Scripts/Editor/PhysicanimGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static void ShowWindow()
void OnGUI()
{
//Selected Object Fields
GUILayout.Label("Please select a ridgged character model to be converted into an Physanim~* active ragdoll.", EditorStyles.boldLabel);
GUILayout.Label("Physicanim Control Panel", EditorStyles.boldLabel);
GUILayout.Box("Please select a rigged character model to be converted into an Physicanim active ragdoll.");
//selectedObj = EditorGUILayout.ObjectField("Selected Object",Selection.activeObject, typeof(Object),true);
charModelObj = (GameObject)EditorGUILayout.ObjectField("Character Model:",Selection.activeGameObject, typeof(GameObject),true);

Expand All @@ -35,12 +36,13 @@ void OnGUI()
if (charModelObj) { charRig = GetRig(charModelObj); } //if selected GameObject has rig set charRig
else { charRig = null; }
Avatar avField = (Avatar)EditorGUILayout.ObjectField("Avatar (e.g: Rig, Skeleton):", charRig, typeof(Avatar),true);
GUI.enabled = true;

if(GUILayout.Button("Open Ragdoll Builder"))
if (GUILayout.Button("Create Active Ragdoll"))
{
//ScriptableWizard rdBuilderWizard = ScriptableWizard.DisplayWizard<ActiveRagdollBuilder>("~* Active Ragdoll Builder");
ActiveRagdollBuilder rdBuilder = ScriptableWizard.DisplayWizard<ActiveRagdollBuilder>("~* Active Ragdoll Builder");
//Depending on ARagBuilder reference, could open window or not.
//ActiveRagdollBuilder rdBuilder = ScriptableWizard.DisplayWizard<ActiveRagdollBuilder>("~* Active Ragdoll Builder");
//ActiveRagdollBuilder rdBuilder = EditorWindow.GetWindow<ActiveRagdollBuilder>("~* Active Ragdoll Builder");
ActiveRagdollBuilder rdBuilder = new ActiveRagdollBuilder(); //Doesn't display window

//set each parameter in ragdoll builder from animator avatar
rdBuilder.pelvis = charAnim.GetBoneTransform(HumanBodyBones.Hips);
Expand All @@ -60,6 +62,7 @@ void OnGUI()
rdBuilder.OnWizardUpdate();
rdBuilder.OnWizardCreate(); //Create ragdoll using wizard
}
GUI.enabled = true;
}

//Get the avatar from any charactermodel. in scene or assets
Expand Down

0 comments on commit 33e30ac

Please sign in to comment.