質問編集履歴

2

文章を修正

2022/03/19 08:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- 提示プロパティですが以下の動作を実現したいのですが色々パラメーターを触りましたが方法がわかりません。これはどうやって実装するのでしょうか?現状ではキャラクターが動くとカメラがキャラクターの背後に合わってしまいやりたい事とは違います。
1
+ 提示プロパティですが以下の動作を実現したいのですが色々パラメーターを触りましたが方法がわかりません。これはどうやって実装するのでしょうか?現状ではキャラクターが動くとカメラがキャラクターの背後に合わってしまいやりたい事とは違います。左右は実装出来たのですが上下が実装出来ません。`提示画像の赤い円の上下版みたいな操作を実装したいです。`
2
2
 
3
3
 
4
4
  ##### 実現したい事
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
-
9
+ 参考サイト:https://qiita.com/vodef6/items/e107a110d16f02d6530a
10
10
  参考サイト:https://light11.hatenadiary.com/entry/2019/10/24/220542
11
11
 
12
12
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-03-19/7e8660e6-487e-48a3-8119-7886c655b6bd.png)
@@ -21,7 +21,7 @@
21
21
  public class CameraControl : MonoBehaviour
22
22
  {
23
23
  public GameObject player;
24
- public CinemachineVirtualCamera camera;
24
+ //public CinemachineVirtualCamera camera;
25
25
  public float rotateSpeed = 5; //回転速度
26
26
 
27
27
  private Vector3 offset; //プレイヤーとの距離
@@ -29,7 +29,7 @@
29
29
  // Start is called before the first frame update
30
30
  void Start()
31
31
  {
32
- camera = GetComponent<CinemachineVirtualCamera>();
32
+ //camera = GetComponent<CinemachineVirtualCamera>();
33
33
 
34
34
  offset = player.transform.position;
35
35
  }
@@ -48,7 +48,7 @@
48
48
  /*########################################## 追尾 ##########################################*/
49
49
  private void Move()
50
50
  {
51
- transform.position += player.transform.position - offset;
51
+ //transform.position += player.transform.position - offset;
52
52
  offset = player.transform.position;
53
53
 
54
54
 
@@ -61,33 +61,19 @@
61
61
  float inputVertical = Input.GetAxis("Right_Vertical");
62
62
 
63
63
 
64
- Vector3 angle = new Vector3(0,0,0);
64
+ Vector3 angle = new Vector3(inputHorizontal, 0, inputVertical);
65
-
66
- if(Mathf.Abs(inputHorizontal ) > 0.4)
67
- {
68
- angle.x = inputHorizontal * rotateSpeed;
69
- }
70
- else
71
- {
72
- angle.x = 0;
73
- }
74
-
75
- if (Mathf.Abs(inputVertical) > 0.4)
76
- {
77
- angle.y = inputVertical * rotateSpeed;
78
- }
79
- else
80
- {
81
- angle.y = 0;
82
- }
83
65
 
84
66
 
85
-
67
+ if(angle.magnitude > 0.4)
86
-
68
+ {
69
+ //GetComponent<CinemachineVirtualCamera>().GetCinemachineComponent<CinemachineOrbitalTransposer>().m_Heading.m_Bias += inputHorizontal * rotateSpeed; //Biasを操作
70
+ GetComponent<CinemachineVirtualCamera>().GetCinemachineComponent<CinemachineOrbitalTransposer>().m_FollowOffset.y -= inputVertical * rotateSpeed; //Biasを操作
87
- camera.transform.RotateAround(player.transform.position, Vector3.up, angle.x);
71
+ //transform.RotateAround(player.transform.position, Vector3.up, inputHorizontal * rotateSpeed);
88
- camera.transform.RotateAround(player.transform.position, transform.right, angle.y);
72
+ transform.RotateAround(player.transform.position, transform.right, inputVertical * rotateSpeed);
73
+ }
89
74
  }
90
75
  }
76
+
91
77
 
92
78
  ```
93
79
  ##### Player

1

文章を修正

2022/03/19 07:58

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,5 @@
1
- 提示プロパティですが以下の動作を実現したいのですが色々パラメーターを触りましたが方法がわかりません。これはどうやって実装するのでしょうか?
1
+ 提示プロパティですが以下の動作を実現したいのですが色々パラメーターを触りましたが方法がわかりません。これはどうやって実装するのでしょうか?現状ではキャラクターが動くとカメラがキャラクターの背後に合わってしまいやりたい事とは違います。
2
+
2
3
 
3
4
  ##### 実現したい事
4
5
  モンハン、マリオ64等であるプレイヤーを中心にカメラが回転移動して、カメラから見た方向にプレイヤーが移動するというカメラ処理です。
@@ -8,8 +9,8 @@
8
9
 
9
10
  参考サイト:https://light11.hatenadiary.com/entry/2019/10/24/220542
10
11
 
12
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-03-19/7e8660e6-487e-48a3-8119-7886c655b6bd.png)
11
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-03-19/2cdfd453-8366-4375-a790-15ca6e53fd95.png)
13
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-03-19/0b436dcb-6a41-46c9-ab26-cf7fb654ede1.png)
12
-
13
14
  ##### Camera
14
15
  ```cs
15
16
  using System.Collections;