提交动画相关内容个、
This commit is contained in:
@@ -5,6 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public enum PlayerState
|
||||
{
|
||||
idle = 0,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
@@ -47,13 +48,12 @@ namespace NBF
|
||||
{
|
||||
_cameraAsset.fppVCam.LookAt = player.FppLook;
|
||||
_cameraAsset.fppVCam.Follow = player.ModelAsset.NeckTransform;
|
||||
// _cameraAsset.fppVCam.follow
|
||||
// _cameraAsset.fppVCam.ResolveFollow()
|
||||
player.ModelAsset.LookIk.solver.target = player.FppLook;
|
||||
}
|
||||
|
||||
_cameraAsset.fppVCam.Priority = 10;
|
||||
_cameraAsset.tppVCam.Priority = 0;
|
||||
StartCoroutine(SnapToTarget());
|
||||
}
|
||||
|
||||
public void SetFppLook(Transform fppCamLook)
|
||||
@@ -65,5 +65,22 @@ namespace NBF
|
||||
{
|
||||
_cameraAsset.fppVCam.Follow = fppCamFollow;
|
||||
}
|
||||
|
||||
IEnumerator SnapToTarget()
|
||||
{
|
||||
// 等 Cinemachine 先激活并跑一帧
|
||||
yield return null;
|
||||
Transform follow = _cameraAsset.fppVCam.Follow;
|
||||
|
||||
_cameraAsset.fppVCam.OnTargetObjectWarped(
|
||||
follow,
|
||||
follow.position - _cameraAsset.fppVCam.transform.position
|
||||
);
|
||||
|
||||
// _cameraAsset.fppVCam.OnTargetObjectWarped(
|
||||
// FPlayer.Instance.ModelAsset.NeckTransform,
|
||||
// FPlayer.Instance.ModelAsset.NeckTransform.position - _cameraAsset.fppVCam.transform.position
|
||||
// );
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Editor/Test.meta
Normal file
3
Assets/Scripts/Editor/Test.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63016c524b454431b06d891415ccdf5e
|
||||
timeCreated: 1767354854
|
||||
21
Assets/Scripts/Editor/Test/PlayerAnimatorEditor.cs
Normal file
21
Assets/Scripts/Editor/Test/PlayerAnimatorEditor.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[CustomEditor(typeof(PlayerAnimator))]
|
||||
public class PlayerAnimatorEditor : Editor
|
||||
{
|
||||
private PlayerAnimator _target;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_target = target as PlayerAnimator;
|
||||
// lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Editor/Test/PlayerAnimatorEditor.cs.meta
Normal file
3
Assets/Scripts/Editor/Test/PlayerAnimatorEditor.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03298da249bf4d0d86c372beb4d5dc48
|
||||
timeCreated: 1767354859
|
||||
@@ -73,15 +73,19 @@ namespace NBF
|
||||
|
||||
public IEnumerator UseItem(ItemInfo item)
|
||||
{
|
||||
if (Data.ChangeItem) yield break;
|
||||
Data.ChangeItem = true;
|
||||
var itemType = item?.ConfigId.GetItemType();
|
||||
if (itemType == ItemType.Rod)
|
||||
{
|
||||
//判断旧的是否要收回
|
||||
if (Rod != null)
|
||||
yield return UnUseItemConfirm();
|
||||
|
||||
Data.IsLureRod = true;
|
||||
var rodType = (ItemSubType)item.Config.Type;
|
||||
if (rodType == ItemSubType.RodTele)
|
||||
{
|
||||
yield return Rod.Destroy();
|
||||
Tackles.Remove(Rod);
|
||||
Rod = null;
|
||||
Data.IsLureRod = false;
|
||||
}
|
||||
|
||||
Rod =
|
||||
@@ -91,15 +95,25 @@ namespace NBF
|
||||
Tackles.Add(Rod);
|
||||
OnFishingSetEquiped?.Invoke(Rod);
|
||||
}
|
||||
|
||||
Data.ChangeItem = false;
|
||||
}
|
||||
|
||||
public IEnumerator UnUseItem()
|
||||
{
|
||||
OnFishingSetUnequip?.Invoke();
|
||||
if (Data.ChangeItem) yield break;
|
||||
Data.ChangeItem = true;
|
||||
yield return UnUseItemConfirm();
|
||||
Data.ChangeItem = false;
|
||||
}
|
||||
|
||||
private IEnumerator UnUseItemConfirm()
|
||||
{
|
||||
if (Rod != null)
|
||||
{
|
||||
yield return new WaitForSeconds(0.35f);
|
||||
OnFishingSetUnequip?.Invoke();
|
||||
yield return Rod.Destroy();
|
||||
yield return new WaitForSeconds(0.35f);
|
||||
Destroy(Rod.gameObject);
|
||||
Tackles.Remove(Rod);
|
||||
Rod = null;
|
||||
|
||||
@@ -8,10 +8,18 @@ namespace NBF
|
||||
private PlayerState _previousPlayerState = PlayerState.idle;
|
||||
private PlayerState _playerState;
|
||||
|
||||
public bool ChangeItem;
|
||||
public bool Run;
|
||||
public bool IsGrounded;
|
||||
public float Speed;
|
||||
public float RotationSpeed;
|
||||
public float ReelSpeed;
|
||||
public float LineTension;
|
||||
|
||||
/// <summary>
|
||||
/// 是否路亚竿
|
||||
/// </summary>
|
||||
public bool IsLureRod;
|
||||
|
||||
public Vector2 MoveInput;
|
||||
|
||||
@@ -25,10 +33,27 @@ namespace NBF
|
||||
{
|
||||
_previousPlayerState = _playerState;
|
||||
_playerState = value;
|
||||
NextState = value;
|
||||
OnStateChange?.Invoke(_playerState);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private PlayerState NextState;
|
||||
|
||||
public event Action<PlayerState> OnStateChange;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
NextState = State;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (NextState != State)
|
||||
{
|
||||
State = NextState;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace NBF
|
||||
public Animator _Animator;
|
||||
public FPlayer Player { get; private set; }
|
||||
|
||||
private bool _isTorsoLayerEnabled;
|
||||
private bool _isRodLayerEnabled;
|
||||
private bool _isInit;
|
||||
private PlayerIK _IK;
|
||||
private MagicBlending _magicBlending;
|
||||
@@ -45,7 +45,8 @@ namespace NBF
|
||||
public static readonly int PreciseIdle = Animator.StringToHash("Precise Idle");
|
||||
|
||||
|
||||
public static readonly string Torso = "Torso";
|
||||
public static readonly string LureRodLayer = "LureRod";
|
||||
public static readonly string HandRodLayer = "HandRod";
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -73,7 +74,7 @@ namespace NBF
|
||||
|
||||
private void OnFishingSetUnequip()
|
||||
{
|
||||
_isTorsoLayerEnabled = false;
|
||||
_isRodLayerEnabled = false;
|
||||
_IK.SetBipedLeftHandIK(enabled: false, null);
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ namespace NBF
|
||||
{
|
||||
if (item is FRod rod)
|
||||
{
|
||||
_isTorsoLayerEnabled = true;
|
||||
_isRodLayerEnabled = true;
|
||||
// var reel = Player.Rod.Reel;
|
||||
// _IK.SetBipedLeftHandIK(enabled: false, reel.FingersIKAnchor);
|
||||
}
|
||||
@@ -229,9 +230,19 @@ namespace NBF
|
||||
_Animator.SetBool(OnGround, _IsInVehicle || Player.Data.IsGrounded);
|
||||
_Animator.SetFloat(RodRight, rod.x);
|
||||
_Animator.SetFloat(RodForward, rod.y);
|
||||
float layerWeight = _Animator.GetLayerWeight(_Animator.GetLayerIndex(Torso));
|
||||
SetLayerWeight(Torso,
|
||||
Mathf.MoveTowards(layerWeight, _isTorsoLayerEnabled ? 1f : 0f, Time.deltaTime * 3f));
|
||||
|
||||
|
||||
var isHandRodLayerEnabled = _isRodLayerEnabled && !Player.Data.IsLureRod ? 1 : 0;
|
||||
|
||||
float handRodLayerWeight = _Animator.GetLayerWeight(_Animator.GetLayerIndex(HandRodLayer));
|
||||
SetLayerWeight(HandRodLayer,
|
||||
Mathf.MoveTowards(handRodLayerWeight, isHandRodLayerEnabled, Time.deltaTime * 3f));
|
||||
|
||||
|
||||
var isLureRodLayerEnabled = _isRodLayerEnabled && Player.Data.IsLureRod ? 1 : 0;
|
||||
float lureRodLayerWeight = _Animator.GetLayerWeight(_Animator.GetLayerIndex(LureRodLayer));
|
||||
SetLayerWeight(LureRodLayer,
|
||||
Mathf.MoveTowards(lureRodLayerWeight, isLureRodLayerEnabled, Time.deltaTime * 3f));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user