private void UpdateBones(PlayerEntity player) { var orientation = player.orientation; var networkAnimator = player.networkAnimator; var characterBoneInterface = player.characterBoneInterface; var thirdPersonAppearance = player.thirdPersonAppearance; var characterBone = player.characterBone; var characterControllerInterface = player.characterControllerInterface; characterBoneInterface.CharacterBone.Peek(thirdPersonAppearance.PeekDegree); try { _subCharacterBoneUpdateInfo.BeginProfileOnlyEnableProfile(); var param = new CodeRigBoneParam { PitchAmplitude = orientation.Pitch, OverlayAnimationWeight = networkAnimator.AnimatorLayers[NetworkAnimatorLayer.PlayerUpperBodyOverlayLayer].Weight, PostureWhenOverlay = thirdPersonAppearance.Posture, // 预测时,IK不生效 IKActive = PlayerEntityUtility.ActiveIK(thirdPersonAppearance.Action, thirdPersonAppearance.Posture, thirdPersonAppearance.NextPosture, thirdPersonAppearance.Movement), HeadPitch = characterBone.PitchHeadAngle, HeadYaw = characterBone.RotHeadAngle, CurrentHandPitch = characterBone.CurrentPitchHandAngle, WeaponRot = characterBone.WeaponRot, FirstPersonPositionOffset = characterBone.FirstPersonPositionOffset, FirstPersonRotationOffset = characterBone.FirstPersonRotationOffset, FirstPersonSightOffset = characterBone.FirstPersonSightOffset }; // code controlled pose characterBoneInterface.CharacterBone.WeaponRotPlayback(param); characterBoneInterface.CharacterBone.Update(param); } finally { _subCharacterBoneUpdateInfo.EndProfileOnlyEnableProfile(); } try { _subCharacterControllerUpdateInfo.BeginProfileOnlyEnableProfile(); player.characterContoller.Value.SetCurrentControllerType(ThirdPersonPostureTool.ConvertToPostureInConfig(thirdPersonAppearance.Posture)); // 更新包围盒 if (thirdPersonAppearance.NeedUpdateController) { characterControllerInterface.CharacterController.SetCharacterControllerHeight(thirdPersonAppearance.CharacterHeight, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController, thirdPersonAppearance.CharacterStandHeight); characterControllerInterface.CharacterController.SetCharacterControllerCenter(thirdPersonAppearance.CharacterCenter, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); characterControllerInterface.CharacterController.SetCharacterControllerRadius(thirdPersonAppearance.CharacterRadius, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); } } finally { _subCharacterControllerUpdateInfo.EndProfileOnlyEnableProfile(); } }
public static void UpdateTransform(PlayerEntity player, NetworkAnimatorComponent networkAnimator, PredictedAppearanceComponent appearance, Orientation orientation) { if (!player.hasAppearanceInterface) { return; } //Logger.InfoFormat("replay pose, networkAnimatior:BaseClientTime{0}, server Time:{1}", networkAnimator.BaseClientTime, networkAnimator.BaseServerTime); // Animation PoseReplayer.ReplayPose(networkAnimator.AnimatorLayers, networkAnimator.AnimatorParameters, player.thirdPersonAnimator.UnityAnimator); // equipment(pan) player.appearanceInterface.Appearance.SyncFrom(player.latestAppearance); player.appearanceInterface.Appearance.SyncFrom(appearance); player.appearanceInterface.Appearance.TryRewind(); player.characterBoneInterface.CharacterBone.Peek(player.thirdPersonAppearance.PeekDegree); CodeRigBoneParam param = new CodeRigBoneParam { PitchAmplitude = orientation.Pitch, OverlayAnimationWeight = networkAnimator.AnimatorLayers[NetworkAnimatorLayer.PlayerUpperBodyOverlayLayer].Weight, PostureWhenOverlay = player.thirdPersonAppearance.Posture, // 预测时,IK不生效 IKActive = ActiveIK(player.thirdPersonAppearance.Action, player.thirdPersonAppearance.Posture), HeadPitch = player.characterBone.PitchHeadAngle, HeadYaw = player.characterBone.RotHeadAngle, HandPitch = player.characterBone.PitchHandAngle, HeadRotProcess = player.characterBone.HeadRotProcess, IsHeadRotCW = player.characterBone.IsHeadRotCW }; // code controlled pose player.characterBoneInterface.CharacterBone.Update(param); // 更新包围盒 if (player.thirdPersonAppearance.NeedUpdateController) { player.characterControllerInterface.CharacterController.SetCharacterControllerHeight(player.thirdPersonAppearance.CharacterHeight); player.characterControllerInterface.CharacterController.SetCharacterControllerCenter(player.thirdPersonAppearance.CharacterCenter); player.characterControllerInterface.CharacterController.SetCharacterControllerRadius(player.thirdPersonAppearance.CharacterRadius); } player.characterContoller.Value.SetCurrentControllerType(ThirdPersonPostureTool.ConvertToPostureInConfig(player.thirdPersonAppearance.Posture)); }
public static void UpdateTransform(PlayerEntity player, NetworkAnimatorComponent networkAnimator, PredictedAppearanceComponent appearance, OrientationComponent orientation) { if (!player.hasAppearanceInterface) { return; } //Logger.InfoFormat("replay pose, networkAnimatior:BaseClientTime{0}, server Time:{1}", networkAnimator.BaseClientTime, networkAnimator.BaseServerTime); // Animation Animator.ClearAnimatorJobContainer(); PoseReplayer.ReplayPose(networkAnimator.AnimatorLayers, networkAnimator.AnimatorParameters, player.thirdPersonAnimator.UnityAnimator); Animator.BatchUpdate(); Animator.ClearAnimatorJobContainer(); // equipment(pan) var appearanceInterface = player.appearanceInterface; appearanceInterface.Appearance.SyncLatestFrom(player.latestAppearance); appearanceInterface.Appearance.SyncPredictedFrom(appearance); appearanceInterface.Appearance.TryRewind(); var characterBoneInterface = player.characterBoneInterface; var thirdPersonAppearance = player.thirdPersonAppearance; var characterBone = player.characterBone; var characterControllerInterface = player.characterControllerInterface; characterBoneInterface.CharacterBone.Peek(thirdPersonAppearance.PeekDegree); var param = new CodeRigBoneParam { PitchAmplitude = orientation.Pitch, OverlayAnimationWeight = networkAnimator.AnimatorLayers[NetworkAnimatorLayer.PlayerUpperBodyOverlayLayer].Weight, PostureWhenOverlay = thirdPersonAppearance.Posture, // 预测时,IK不生效 IKActive = ActiveIK(thirdPersonAppearance.Action, thirdPersonAppearance.Posture, thirdPersonAppearance.NextPosture, thirdPersonAppearance.Movement), HeadPitch = characterBone.PitchHeadAngle, HeadYaw = characterBone.RotHeadAngle, HandPitch = characterBone.PitchHandAngle, HeadRotProcess = characterBone.HeadRotProcess, WeaponRot = characterBone.WeaponRot, IsProne = thirdPersonAppearance.Posture == ThirdPersonPosture.Prone, IsHeadRotCW = characterBone.IsHeadRotCW, FirstPersonPositionOffset = characterBone.FirstPersonPositionOffset, FirstPersonRotationOffset = characterBone.FirstPersonRotationOffset, FirstPersonSightOffset = characterBone.FirstPersonSightOffset }; // code controlled pose characterBoneInterface.CharacterBone.WeaponRotPlayback(param); characterBoneInterface.CharacterBone.Update(param); player.characterContoller.Value.SetCurrentControllerType( ThirdPersonPostureTool.ConvertToPostureInConfig(thirdPersonAppearance.Posture)); // 更新包围盒 if (thirdPersonAppearance.NeedUpdateController) { characterControllerInterface.CharacterController.SetCharacterControllerHeight(thirdPersonAppearance .CharacterHeight, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController, thirdPersonAppearance.CharacterStandHeight); characterControllerInterface.CharacterController.SetCharacterControllerCenter(thirdPersonAppearance .CharacterCenter, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); characterControllerInterface.CharacterController.SetCharacterControllerRadius(thirdPersonAppearance .CharacterRadius, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); } }
public static void UpdateTransform(PlayerEntity player, NetworkAnimatorComponent networkAnimator, PredictedAppearanceComponent appearance, OrientationComponent orientation) { if (!player.hasAppearanceInterface) { return; } // Animation Animator.ClearAnimatorJobContainer(); // 流量优化用 // if (networkAnimator.AnimatorParameters == null) // { // networkAnimator.SetAnimatorParamsWithoutChangeData( // NetworkAnimatorUtil.GetAnimatorParams(player.thirdPersonAnimator.UnityAnimator)); // networkAnimator.ConvertCompressDataToStructureData(); // } AnimatorPoseReplayer.ReplayPose(networkAnimator.AnimatorLayers, networkAnimator.AnimatorParameters, player.thirdPersonAnimator.UnityAnimator); Animator.BatchUpdate(); // equipment(pan) var appearanceInterface = player.appearanceInterface; appearanceInterface.Appearance.SyncLatestFrom(player.latestAppearance); appearanceInterface.Appearance.SyncPredictedFrom(appearance); appearanceInterface.Appearance.TryRewind(); var characterBoneInterface = player.characterBoneInterface; var thirdPersonAppearance = player.thirdPersonAppearance; var characterBone = player.characterBone; var characterControllerInterface = player.characterControllerInterface; characterBoneInterface.CharacterBone.Peek(thirdPersonAppearance.PeekDegree); var param = new CodeRigBoneParam { PitchAmplitude = orientation.Pitch, OverlayAnimationWeight = networkAnimator.AnimatorLayers[NetworkAnimatorLayer.PlayerUpperBodyOverlayLayer].Weight, PostureWhenOverlay = thirdPersonAppearance.Posture, // 预测时,IK不生效 IKActive = ActiveIK(thirdPersonAppearance.Action, thirdPersonAppearance.Posture, thirdPersonAppearance.NextPosture, thirdPersonAppearance.Movement), HeadPitch = characterBone.PitchHeadAngle, HeadYaw = characterBone.RotHeadAngle, CurrentHandPitch = characterBone.CurrentPitchHandAngle, WeaponRot = characterBone.WeaponRot, FirstPersonPositionOffset = characterBone.FirstPersonPositionOffset, FirstPersonRotationOffset = characterBone.FirstPersonRotationOffset, FirstPersonSightOffset = characterBone.FirstPersonSightOffset }; // code controlled pose characterBoneInterface.CharacterBone.WeaponRotPlayback(param); characterBoneInterface.CharacterBone.Update(param); player.characterContoller.Value.SetCurrentControllerType( ThirdPersonPostureTool.ConvertToPostureInConfig(thirdPersonAppearance.Posture)); // 更新包围盒 if (thirdPersonAppearance.NeedUpdateController) { characterControllerInterface.CharacterController.SetCharacterControllerHeight(thirdPersonAppearance .CharacterHeight, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController, thirdPersonAppearance.CharacterStandHeight); characterControllerInterface.CharacterController.SetCharacterControllerCenter(thirdPersonAppearance .CharacterCenter, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); characterControllerInterface.CharacterController.SetCharacterControllerRadius(thirdPersonAppearance .CharacterRadius, player.characterContoller.Value.GetCurrentControllerType() == CharacterControllerType.UnityCharacterController); } }