回答編集履歴
1
サンプル追加
test
CHANGED
@@ -5,3 +5,28 @@
|
|
5
5
|
「Freeze Rotation Axes」の設定は、「ターゲットの回転」を設定に合わせて調整すれば実現できそうだけど、ちょっと試してみないとわかりませんね。
|
6
6
|
とりあえずFreezeAxesのことは考えないで `Quaternion.Slerp` を使って試してみてはいかがですか。
|
7
7
|
|
8
|
+
-----
|
9
|
+
追記: こんなスクリプトを書いたら、それっぽく動きましたよ。
|
10
|
+
(別のPCで動かしたので、書き直しているので間違っているかもしれないけど)
|
11
|
+
|
12
|
+
```csharp
|
13
|
+
using UnityEngine;
|
14
|
+
|
15
|
+
public class TestScript : MonoBehaviour {
|
16
|
+
[SerializeField] private Transform target;
|
17
|
+
[SerializeField] private float weight;
|
18
|
+
private Quaternion baseRotation;
|
19
|
+
|
20
|
+
private void Start()
|
21
|
+
{
|
22
|
+
this.baseRotation = this.transform.rotation;
|
23
|
+
}
|
24
|
+
|
25
|
+
private void Update()
|
26
|
+
{
|
27
|
+
this.transform.rotation = Quaternion.Slerp(this.baseRotation,
|
28
|
+
this.target.transform.rotation, this.weight);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
```
|
32
|
+
|