質問編集履歴
1
修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,9 +66,11 @@
|
|
66
66
|
|
67
67
|
```ここに言語を入力
|
68
68
|
|
69
|
+
float distance = 後ろ足からHitしている地面への距離;
|
70
|
+
|
69
71
|
_Height=キャラクターの中心までの長さ
|
70
72
|
|
71
|
-
|
73
|
+
|
72
74
|
|
73
75
|
if (distance > _Height)
|
74
76
|
|
@@ -80,25 +82,21 @@
|
|
80
82
|
|
81
83
|
float diference = _Height - distance;
|
82
84
|
|
83
|
-
Vector3 Add =
|
85
|
+
Vector3 Add = Gravity * diference;
|
84
86
|
|
85
|
-
if (CurrentAnimState.tagHash == T_Locomotion)
|
87
|
+
if (CurrentAnimState.tagHash == T_Locomotion)//もし移動中だったら
|
86
88
|
|
87
89
|
{
|
88
90
|
|
89
|
-
_transform.position = _transform.position + Add;
|
91
|
+
_transform.position = _transform.position + Add;
|
90
92
|
|
91
|
-
}
|
93
|
+
}
|
92
|
-
|
93
|
-
else
|
94
|
-
|
95
|
-
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime * realsnap);
|
96
94
|
|
97
95
|
}
|
98
96
|
|
99
97
|
}
|
100
98
|
|
101
|
-
|
99
|
+
|
102
100
|
|
103
101
|
else
|
104
102
|
|
@@ -110,22 +108,24 @@
|
|
110
108
|
|
111
109
|
float diference = _Height - distance;
|
112
110
|
|
113
|
-
Vector3 Add =
|
111
|
+
Vector3 Add = Gravity* diference;
|
114
112
|
|
115
|
-
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime
|
113
|
+
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime);
|
116
114
|
|
117
|
-
|
118
|
-
|
119
|
-
if (RealAnimatorState(T_Locomotion) || RealAnimatorState(T_Idle) || RealAnimatorState(T_JEnd)) //Restore the Contraints if is in any of these states
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
_rigidbody.constraints = Still_Constraints;
|
124
|
-
|
125
|
-
|
115
|
+
}
|
126
|
-
|
127
|
-
}
|
128
116
|
|
129
117
|
}
|
130
118
|
|
131
119
|
```
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
ここでは惑星の位置をVector3(0,0,0);
|
126
|
+
|
127
|
+
回転を Euler(0,0,0);で話します。
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
おかしな挙動としては、移動先の地面のY位置が現在のキャラクター位置Yよりも0に近づく場合に、地面との判定が取れない瞬間が有り、一瞬判定が無い者として扱われてしまい、地面から離れてしまいます。
|