结构大修改,改成朴实无华的结构,不过度架构。能跑就行
This commit is contained in:
13
Assets/Scripts/Fishing2~/Mono/CameraAsset.cs
Normal file
13
Assets/Scripts/Fishing2~/Mono/CameraAsset.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Cinemachine;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Fishing2
|
||||
{
|
||||
public class CameraAsset : MonoBehaviour
|
||||
{
|
||||
public CinemachineVirtualCamera fppVCam;
|
||||
|
||||
public CinemachineVirtualCamera tppVCam;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing2~/Mono/CameraAsset.cs.meta
Normal file
3
Assets/Scripts/Fishing2~/Mono/CameraAsset.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dd3e6b2217c463e94e32f15c4ea3c5c
|
||||
timeCreated: 1765306413
|
||||
58
Assets/Scripts/Fishing2~/Mono/PlayerArm.cs
Normal file
58
Assets/Scripts/Fishing2~/Mono/PlayerArm.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerArm : MonoBehaviour
|
||||
{
|
||||
public bool IsLeft;
|
||||
public LimbIK IK;
|
||||
public Transform RodContainer;
|
||||
public Transform LeftRigMagnet;
|
||||
public FingerRig FingerRig;
|
||||
public PlayerShoulder Shoulder;//PlayerShoulder
|
||||
|
||||
[HideInInspector] public float interactionTargetWeight;
|
||||
|
||||
|
||||
public void SetReelHandle(ReelAsset asset)
|
||||
{
|
||||
IK.solver.target = asset.handle;
|
||||
IK.enabled = true;
|
||||
|
||||
// var fingers = FingerRig.fingers;
|
||||
// foreach (var finger in fingers)
|
||||
// {
|
||||
// finger.target = asset.handleEnd;
|
||||
// }
|
||||
|
||||
// // 启用整体控制
|
||||
// FingerRig.weight = 1f;
|
||||
//
|
||||
// // 绑定大拇指和食指的目标
|
||||
// FingerRig.fingers[0].target = asset.handleEnd; // Thumb
|
||||
// FingerRig.fingers[1].target = asset.handleEnd; // Index
|
||||
//
|
||||
// FingerRig.fingers[0].weight = 1f;
|
||||
// FingerRig.fingers[1].weight = 1f;
|
||||
|
||||
// 其余手指握拳(不绑定 target)
|
||||
for (int i = 2; i < 5; i++)
|
||||
{
|
||||
FingerRig.fingers[i].target = null;
|
||||
FingerRig.fingers[i].weight = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveTowardsInteraction()
|
||||
{
|
||||
if (!IK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IK.solver.SetIKPositionWeight(Mathf.MoveTowards(IK.solver.IKPositionWeight,
|
||||
interactionTargetWeight, Time.deltaTime * 2f));
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing2~/Mono/PlayerArm.cs.meta
Normal file
3
Assets/Scripts/Fishing2~/Mono/PlayerArm.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed33e261a2784ee0814ceaa6c88aefdf
|
||||
timeCreated: 1756821001
|
||||
37
Assets/Scripts/Fishing2~/Mono/PlayerShoulder.cs
Normal file
37
Assets/Scripts/Fishing2~/Mono/PlayerShoulder.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerShoulder : MonoBehaviour
|
||||
{
|
||||
private Vector3 startEulerAngles;
|
||||
private const int MaxAngle = 30;
|
||||
private const int MinAngle = -30;
|
||||
|
||||
|
||||
public float TestZ;
|
||||
private void Awake()
|
||||
{
|
||||
startEulerAngles = transform.localEulerAngles;
|
||||
}
|
||||
|
||||
public void SetCameraEulerAngleX(float value)
|
||||
{
|
||||
value = (value > 180f) ? value - 360f : value;
|
||||
Debug.Log($"value={value}");
|
||||
var addValue = value * -1;
|
||||
if (addValue > MaxAngle)
|
||||
{
|
||||
addValue = MaxAngle;
|
||||
}
|
||||
else if (addValue < MinAngle)
|
||||
{
|
||||
addValue = MinAngle;
|
||||
}
|
||||
|
||||
transform.localEulerAngles =
|
||||
new Vector3(addValue + startEulerAngles.x, startEulerAngles.y, TestZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Fishing2~/Mono/PlayerShoulder.cs.meta
Normal file
3
Assets/Scripts/Fishing2~/Mono/PlayerShoulder.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f85286904d2d45738c4b415f3503d4ab
|
||||
timeCreated: 1756820965
|
||||
Reference in New Issue
Block a user