質問編集履歴
1
修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,35 +32,35 @@
|
|
32
32
|
```
|
33
33
|
|
34
34
|
```ここに言語を入力
|
35
|
+
float distance = 後ろ足からHitしている地面への距離;
|
35
36
|
_Height=キャラクターの中心までの長さ
|
36
|
-
|
37
|
+
|
37
38
|
if (distance > _Height)
|
38
39
|
{
|
39
40
|
if (!isInAir && !swim)
|
40
41
|
{
|
41
42
|
float diference = _Height - distance;
|
42
|
-
Vector3 Add =
|
43
|
+
Vector3 Add = Gravity * diference;
|
43
|
-
if (CurrentAnimState.tagHash == T_Locomotion)
|
44
|
+
if (CurrentAnimState.tagHash == T_Locomotion)//もし移動中だったら
|
44
45
|
{
|
45
|
-
_transform.position = _transform.position + Add;
|
46
|
+
_transform.position = _transform.position + Add;
|
46
|
-
}
|
47
|
+
}
|
47
|
-
else
|
48
|
-
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime * realsnap);
|
49
48
|
}
|
50
49
|
}
|
51
|
-
|
50
|
+
|
52
51
|
else
|
53
52
|
{
|
54
53
|
if (!fall && (!isJumping(0.5f, true)) && !IsInAir)
|
55
54
|
{
|
56
55
|
float diference = _Height - distance;
|
57
|
-
Vector3 Add =
|
56
|
+
Vector3 Add = Gravity* diference;
|
58
|
-
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime
|
57
|
+
_transform.position = Vector3.Lerp(_transform.position, _transform.position + Add, Time.deltaTime);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
```
|
59
61
|
|
60
|
-
|
62
|
+
|
61
|
-
{
|
62
|
-
|
63
|
+
ここでは惑星の位置をVector3(0,0,0);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
64
|
+
回転を Euler(0,0,0);で話します。
|
65
|
+
|
66
|
+
おかしな挙動としては、移動先の地面のY位置が現在のキャラクター位置Yよりも0に近づく場合に、地面との判定が取れない瞬間が有り、一瞬判定が無い者として扱われてしまい、地面から離れてしまいます。
|