任务:针对上次答辩的反馈更新内容

子任务:更新马足骨骼
上次被要求马更加仿真,则需要马蹄再加一截骨骼
1.替换上新的骨骼
DONE
2.仍用两节式的控制,试了其他解算器效果不行,腿会扭曲成自然中没有的样子
DONE
3.用代码控制最后一节马脚的骨骼的旋转,当马腿抬起,旋转到一个状态,当马腿方下,旋转到另一个状态,用插值Lerp的方法
DONE

明日预计完成
子任务:添加马尾马头部分的运动
This commit is contained in:
Roman 2022-08-11 22:44:41 +08:00
parent 03b4c4d9f2
commit a4323c1fdb
3 changed files with 5406 additions and 7050 deletions

File diff suppressed because it is too large Load Diff

View File

@ -114,6 +114,17 @@ public class Horse : MonoBehaviour
[BoxGroup("马的基本运动信息")][Header("加速倍率")]
public float accelerationRate = 1f;
/// <summary>
/// 最后一节马足的骨骼,必须按照左前、右前、左后、右后的顺序绑定
/// </summary>
[ BoxGroup("必须绑定的物体")][Header("最后一节马足的骨骼,必须按照左前、右前、左后、右后的顺序绑定")]
public Transform[] lastFoots;
[BoxGroup("马的基本运动信息")][Header("最后一节马前脚的旋转区间")]
public Vector2 lastFrontFootRotationRange;
[BoxGroup("马的基本运动信息")][Header("最后一节马后脚的旋转区间")]
public Vector2 lastBackFootRotationRange;
@ -161,6 +172,11 @@ public class Horse : MonoBehaviour
/// 马蹄前一帧的位置
/// </summary>
public Vector3 footPreviousPosition;
/// <summary>
/// 最后一节马足的骨骼Transform需要模拟其弯曲
/// </summary>
public Transform lastFootTransform;
}
private foot[] foots;
@ -307,6 +323,8 @@ public class Horse : MonoBehaviour
MoveFoot();
//让马整体运动
MoveHorse();
//计算此时马脚在Y轴上的进程并根据此进程对马蹄旋转插值模拟最后一节马蹄的弯曲
CaculateLastFootRotation();
//跳跃检测和物理实现
if(horseState == HorseState.Jump) CheckJump();
}
@ -318,6 +336,25 @@ public class Horse : MonoBehaviour
CaculateFootInputCharge();
}
void CaculateLastFootRotation(){
for(int i = 0; i < 4; i++){
//用脚底深度减去马足深度ABS。得到一个Progress
float footBottle = (i < 2) ? frontFoot.position.y : backFoot.position.y;
float footY = foots[i].footRealTransform.position.y;
float progress = Mathf.Abs(footBottle - footY) / (2*footMoveRadius);
//if(i == 1) Debug.Log("左前脚Progress" + progress);
Vector2 lastFootRotationRange = (i < 2) ? lastFrontFootRotationRange : lastBackFootRotationRange;
//插值
foots[i].lastFootTransform.rotation = Quaternion.Euler(
0,0,
Mathf.Lerp(
lastFootRotationRange.x,
lastFootRotationRange.y,
progress)
);
}
}
void CaculateFootInputCharge()
{
//计算上一帧和这一帧的输入的角度差
@ -337,7 +374,7 @@ public class Horse : MonoBehaviour
//估算了一下充能最快大概是每秒3000.这里/3000 * 时间即可得到一个大约0-1的值
footInputCharge /= (3000 * accelerationTime);
Debug.Log("footInputCharge: " + footInputCharge);
//Debug.Log("footInputCharge: " + footInputCharge);
//更新上一帧信息
pInputFrontVector = inputFrontVector;
@ -584,6 +621,10 @@ public class Horse : MonoBehaviour
//
rotateCenter = transform.Find("马死后的旋转中心");
//
for(int i = 0; i < 4; i++){
foots[i].lastFootTransform = lastFoots[i];
}
}
/// <summary>
@ -700,6 +741,4 @@ public class Horse : MonoBehaviour
jumpState = JumpState.Ready;
}
}
}

View File

@ -121,7 +121,7 @@ MonoBehaviour:
m_MinSize: {x: 400, y: 200}
m_MaxSize: {x: 32384, y: 16192}
vertical: 0
controlID: 137
controlID: 21
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@ -141,12 +141,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 608
width: 609.6
height: 722.8
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 121
controlID: 125
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@ -164,10 +164,10 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 608
height: 622.4
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
width: 609.6
height: 411.2
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 13}
m_Panes:
- {fileID: 13}
@ -189,9 +189,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 622.4
width: 608
height: 100.39996
y: 411.2
width: 609.6
height: 311.59998
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 12}
@ -214,9 +214,9 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 608
x: 609.6
y: 0
width: 200
width: 376.80005
height: 722.8
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
@ -240,9 +240,9 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 808
x: 986.4
y: 0
width: 348.80005
width: 170.40002
height: 722.8
m_MinSize: {x: 232, y: 271}
m_MaxSize: {x: 10002, y: 10021}
@ -298,9 +298,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 696
width: 607
height: 79.39996
y: 484.80002
width: 608.6
height: 290.59998
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@ -311,7 +311,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 130, y: 72.999954}
m_TargetSize: {x: 599, y: 336.99997}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@ -326,10 +326,10 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
m_HBaseRangeMin: -52
m_HBaseRangeMax: 52
m_VBaseRangeMin: -29.199982
m_VBaseRangeMax: 29.199982
m_HBaseRangeMin: -239.6
m_HBaseRangeMax: 239.6
m_VBaseRangeMin: -134.79999
m_VBaseRangeMax: 134.79999
m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1
@ -347,23 +347,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 607
height: 58.399963
width: 608.6
height: 269.59998
m_Scale: {x: 1, y: 1}
m_Translation: {x: 303.5, y: 29.199982}
m_Translation: {x: 304.3, y: 134.79999}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -303.5
y: -29.199982
width: 607
height: 58.399963
x: -304.3
y: -134.79999
width: 608.6
height: 269.59998
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 758.75, y: 99.249954}
m_LastWindowPixelSize: {x: 760.75, y: 363.24997}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 00000000000000000000
@ -391,8 +391,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 73.6
width: 607
height: 601.4
width: 608.6
height: 390.2
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@ -402,8 +402,8 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: -100, y: -25.599976}
snapOffset: {x: -100, y: -25.599976}
snapOffsetDelta: {x: 0, y: -0.000030517578}
snapCorner: 3
id: Tool Settings
index: 0
@ -424,7 +424,7 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: 0, y: 0}
snapOffset: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: unity-scene-view-toolbar
@ -607,7 +607,7 @@ MonoBehaviour:
index: 10
layout: 4
m_WindowGUID: 932fa420110f25f488f2a7bbcd1fb02a
m_Gizmos: 1
m_Gizmos: 0
m_OverrideSceneCullingMask: 6917529027641081856
m_SceneIsLit: 1
m_SceneLighting: 1
@ -616,9 +616,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 8.493464, y: -0.7896302, z: -0.11085244}
m_Target: {x: -8.364254, y: 6.7216816, z: -0.22740065}
speed: 2
m_Value: {x: 8.532534, y: -0.9025359, z: -0.10837402}
m_Value: {x: -8.06534, y: 6.497139, z: -0.22087887}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@ -669,9 +669,9 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 5.7554345
m_Target: 15.144942
speed: 2
m_Value: 5.5075927
m_Value: 14.492767
m_Ortho:
m_Target: 1
speed: 2
@ -716,9 +716,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 608
x: 609.60004
y: 73.6
width: 198
width: 374.80005
height: 701.8
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -729,7 +729,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 7809ffff7c09ffffa409ffff280affff781dffff9438fffff840ffff144cffff184cffff1c4cffff204cffff244cffff284cffff504cffffd44cffff704fffffea65ffffb067ffffa468ffff1c6bffff246cffff366effff3c71ffff0479ffffbc8dffff3e90ffff6690ffffca90ffffc893ffffe893ffff4c94ffff7896ffffa096ffff0497ffff8c97ffffb497ffffcc9fffffd49fffffdc9ffffff49fffff58a0ffff0efbffffb4780000060f01003818010028240100ba2801000e2e0100623301003e3501004235010094350100
m_ExpandedIDs: 0abbffff38bdffff6ec1ffffd4c4ffff9ec9ffff50ceffff30ecffff34ecffff3cecffff40ecffff4cecffff50ecffff58ecffff5cecffff68ecffffececffffb2eeffffbceeffffd0eeffffd2eeffffe8eeffff0efbffffae780000ce780000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -773,9 +773,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 808
x: 986.4
y: 73.6
width: 346.80005
width: 168.40002
height: 701.8
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -807,23 +807,23 @@ MonoBehaviour:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 64040100
m_LastClickedID: 66660
m_ExpandedIDs: 00000000207b0000227b0000247b0000267b0000287b00002a7b00002c7b00005e7b0000
m_SelectedIDs: 467c0000
m_LastClickedID: 31814
m_ExpandedIDs: 00000000227c0000247c0000267c0000287c00002a7c00002c7c00002e7c0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: "\u7269\u7406\u6750\u8D28"
m_OriginalName: "\u7269\u7406\u6750\u8D28"
m_Name:
m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 31570
m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 10}
m_SearchString:
@ -837,7 +837,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 00000000207b0000227b0000247b0000267b0000287b00002a7b00002c7b0000
m_ExpandedIDs: 00000000227c0000247c0000267c0000287c00002a7c00002c7c00002e7c0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -892,7 +892,7 @@ MonoBehaviour:
m_ScrollPosition: {x: 0, y: 0}
m_GridSize: 64
m_SkipHiddenPackages: 0
m_DirectoriesAreaWidth: 147
m_DirectoriesAreaWidth: 118.400024
--- !u!114 &16
MonoBehaviour:
m_ObjectHideFlags: 52
@ -928,7 +928,7 @@ MonoBehaviour:
m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: -1
m_LastVerticalScrollValue: 498.40002
m_LastVerticalScrollValue: 0
m_GlobalObjectId:
m_InspectorMode: 0
m_LockTracker: