diff --git a/Editor/HumanoidControl/HumanoidControl_Editor.cs b/Editor/HumanoidControl/HumanoidControl_Editor.cs index d969e7e..0711efb 100644 --- a/Editor/HumanoidControl/HumanoidControl_Editor.cs +++ b/Editor/HumanoidControl/HumanoidControl_Editor.cs @@ -377,24 +377,11 @@ namespace Passer { #region Animations - private SerializedProperty animatorParamForwardProp; - private SerializedProperty animatorParamSidewardProp; - private SerializedProperty animatorParamRotationProp; - private SerializedProperty animatorParamHeightProp; - - - private void InitAnimations(HumanoidControl humanoid) { - - animatorParamForwardProp = serializedObject.FindProperty("animatorParameterForwardIndex"); - animatorParamSidewardProp = serializedObject.FindProperty("animatorParameterSidewardIndex"); - animatorParamRotationProp = serializedObject.FindProperty("animatorParameterRotationIndex"); - animatorParamHeightProp = serializedObject.FindProperty("animatorParameterHeightIndex"); - } + private void InitAnimations(HumanoidControl humanoid) { } bool showAnimatorParameters = false; private void AnimatorInspector(HumanoidControl humanoid) { AnimatorControllerInspector(humanoid); - AnimatorParametersInspector(humanoid); } private void AnimatorControllerInspector(HumanoidControl humanoid) { @@ -423,44 +410,6 @@ namespace Passer { EditorGUILayout.EndHorizontal(); } - private void AnimatorParametersInspector(HumanoidControl humanoid) { - if (showAnimatorParameters && humanoid.animatorEnabled && humanoid.targetsRig.runtimeAnimatorController != null) { - if (animatorParameterNames == null) - animatorParameterNames = GetAnimatorParameters(humanoid); - - EditorGUI.indentLevel++; - - GUIContent forwardSpeedText = new GUIContent( - "Forward Speed", - "Animator parameter controlling the forward motion animation" - ); - animatorParamForwardProp.intValue = SetAnimatorInput(forwardSpeedText, animatorParamForwardProp.intValue, ref humanoid.animatorParameterForward); - - GUIContent sidewardSpeedText = new GUIContent( - "Sideward Speed", - "Animator parameter controlling the sideward motion animation" - ); - animatorParamSidewardProp.intValue = SetAnimatorInput(sidewardSpeedText, animatorParamSidewardProp.intValue, ref humanoid.animatorParameterSideward); - - GUIContent turnSpeedText = new GUIContent( - "Turn Speed", - "Animator parameter controlling the rotation animation" - ); - animatorParamRotationProp.intValue = SetAnimatorInput(turnSpeedText, animatorParamRotationProp.intValue, ref humanoid.animatorParameterRotation); - - GUIContent headHeightText = new GUIContent( - "Head Height", - "Animation parameter controlling the squatting animation" - ); - animatorParamHeightProp.intValue = SetAnimatorInput(headHeightText, animatorParamHeightProp.intValue, ref humanoid.animatorParameterHeight); - - EditorGUI.indentLevel--; - } - else - showAnimatorParameters = false; - - } - protected GUIContent[] animatorParameterNames; public GUIContent[] GetAnimatorParameters(HumanoidControl humanoid) { if (humanoid == null || humanoid.targetsRig.runtimeAnimatorController == null) diff --git a/Runtime/HumanoidControl/Scripts/Animator/Animator_Doc.md.cs b/Runtime/HumanoidControl/Scripts/Animator/Animator_Doc.md.cs index 48b7db0..d165417 100644 --- a/Runtime/HumanoidControl/Scripts/Animator/Animator_Doc.md.cs +++ b/Runtime/HumanoidControl/Scripts/Animator/Animator_Doc.md.cs @@ -9,57 +9,6 @@ /// when setting the Runtime Animator Controller parameter which is standard /// [Unity Animator Controller](https://docs.unity3d.com/Manual/class-AnimatorController.html). /// - /// Humanoid Control can control the animator controller using a number of float Animation - /// Parameters. These can be set in the Params section and refer to the - /// [Animation Parameters](https://docs.unity3d.com/Manual/AnimationParameters.html) - /// of the Animator Controller. - /// - /// float Forward Speed | The forward/backward speed. Negative is backward walking. Unit is units(meters) per second. - /// float Sideward Speed | The left/right speed. Negative is left strafing. Unit is units(meters) per second - /// float Turn Speed | The turning speed around the Y axis. Negative is turning left. Unit is full rotations (360 degrees) per second. - /// float Head Height | The head height relative to the standing position. Negative is crouching. Positive is reaching up. Unit is meters. - /// - /// Please note the unit of the parameters. Great care should be paid to this when creating the animations, - /// because it is not possible to use root motion (see below). - /// If the animation root speed does not match the required units of speed, - /// you can adjust them using the Speed parameter of the Animation State (see - /// [Unity3d – Animation States](https://docs.unity3d.com/Manual/class-State.html)). - /// For example, when the turning animation is set up such that it takes 4 seconds for a full rotation, - /// the Speed parameter should be set to 0.25. - /// - /// Root Motion - /// =========== - /// or the animations to work well they should not contain root motion. - /// This is because we need to be able to move the character from the VR headset, - /// not from the animation, or players will get motion sickness. - /// - /// To get the right behaviour, ensure that the following options are checked on the imported animations: - /// - /// Loop Time -> Loop Pose - /// Root Transform Rotation -> Bake Into PoseRoot Transform Position(Y) -> Bake Into Pose - /// Root Transform Position(XZ) -> Bake Into Pose - /// - /// Animation Restrictions - /// ====================== - /// The animations are controlled by the Animation Parameters which are derived from the head movements. - /// In order to match the movements of the player, the animations should be set in a specific way. - /// - /// - The animation being player when Forward Speed = 1 should ensure - /// that the head speed is exactly 1 unit(meter) per second. - /// If the head speed in the animation is different you may see feet slipping - /// over the ground because the animation is played too fast or too slow. - /// - The Forward Speed should only have effect on the forward/backward (Z-axis) speed of the avatar. - /// If this is not ensured, the animations will be wrong. - /// For example when the head moves to the left when forward speed = 1, the sideward speed will also be activated, - /// resulting in unwanted animations. - /// - The same is true for the Sideward Speed and Turn Speed, - /// but then limited to the sideward (X-axis) motion and rotation along the Y axis. - /// - The Head height is used to change the vertical position of the avatar. - /// A value of -0.3 can result in a crouching with even lower values resulting in a crawling position. - /// Positive values like 0.1 can result in a reaching position when the avatar stands on his toes. - /// - As with the other parameters, the Head Height parameter should only have effect - /// on the Y position of the head.All other movements must be avoided in this animation. - /// /// Targets /// ======= /// When the Animation option is enabled on the Humanoid Control script, diff --git a/Runtime/HumanoidControl/Scripts/Animator/TorsoAnimator.cs b/Runtime/HumanoidControl/Scripts/Animator/TorsoAnimator.cs index 7d00801..b689053 100644 --- a/Runtime/HumanoidControl/Scripts/Animator/TorsoAnimator.cs +++ b/Runtime/HumanoidControl/Scripts/Animator/TorsoAnimator.cs @@ -44,7 +44,6 @@ namespace Passer.Humanoid { Animator targetAnimator = hipsTarget.humanoid.targetsRig; // Don't use procedural if the animator controller plays an animation clip if (targetAnimator.runtimeAnimatorController != null && - hipsTarget.humanoid.animatorParameterForward == null && targetAnimator.GetCurrentAnimatorClipInfoCount(0) > 0) return; diff --git a/Runtime/HumanoidControl/Scripts/HumanoidControl.cs b/Runtime/HumanoidControl/Scripts/HumanoidControl.cs index 8315c1e..effbb88 100644 --- a/Runtime/HumanoidControl/Scripts/HumanoidControl.cs +++ b/Runtime/HumanoidControl/Scripts/HumanoidControl.cs @@ -384,7 +384,7 @@ namespace Passer.Humanoid { if (humanoidNetworking != null) { if (remoteAvatar != null) { - Possessable avatarPossessable = remoteAvatar.GetComponent(); + Possessable avatarPossessable = remoteAvatar.GetComponent(); if (avatarPossessable == null) humanoidNetworking.ChangeAvatar(this, fpAvatarPrefab.name); else @@ -1330,7 +1330,6 @@ namespace Passer.Humanoid { UpdateTargetsAndMovements(); CalculateVelocityAcceleration(); - UpdateAnimation(); UpdatePoseEvent(); } @@ -2178,7 +2177,7 @@ namespace Passer.Humanoid { float leftFootBoneDistance = leftFootTarget.foot.bone.transform.position.y - leftFootTarget.foot.target.transform.position.y; float rightFootBoneDistance = rightFootTarget.foot.bone.transform.position.y - rightFootTarget.foot.target.transform.position.y; if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F) - AdjustTrackingHeight(-0.01F); + AdjustTrackingHeight(-0.01F); } } @@ -2336,35 +2335,6 @@ namespace Passer.Humanoid { } #region Animation - public string animatorParameterForward; - public string animatorParameterSideward; - public string animatorParameterRotation; - public string animatorParameterHeight; - - // needed for the Editor - public int animatorParameterForwardIndex; - public int animatorParameterSidewardIndex; - public int animatorParameterRotationIndex; - public int animatorParameterHeightIndex; - - private void UpdateAnimation() { - if (targetsRig.runtimeAnimatorController != null) { - if (animatorParameterForward != null && animatorParameterForward != "") { - targetsRig.SetFloat(animatorParameterForward, velocity.z); - } - if (animatorParameterSideward != null && animatorParameterSideward != "") { - targetsRig.SetFloat(animatorParameterSideward, velocity.x); - } - if (animatorParameterRotation != null && animatorParameterRotation != "") { - targetsRig.SetFloat(animatorParameterRotation, turningVelocity); - } - - if (animatorParameterHeight != null && animatorParameterHeight != "") { - float relativeHeadHeight = headTarget.neck.target.transform.position.y - avatarNeckHeight; - targetsRig.SetFloat(animatorParameterHeight, relativeHeadHeight); - } - } - } private void PostAnimationCorrection() {