teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

Hierarchyの構成とスクリプトの追加

2020/01/20 07:05

投稿

atsushi3105
atsushi3105

スコア8

title CHANGED
File without changes
body CHANGED
@@ -7,4 +7,21 @@
7
7
  具体的なコードの組み方がわからないです
8
8
  どなたかお力を????‍♂️
9
9
 
10
- ![イメージ説明](398260e923993c3df97c1d7a11c55edc.jpeg)
10
+ ![イメージ説明](398260e923993c3df97c1d7a11c55edc.jpeg)
11
+ ![イメージ説明](02196c47cf2acb04d0f3aa9399ecc864.png)
12
+
13
+ ```C#
14
+ using System.Collections;
15
+ using System.Collections.Generic;
16
+ using UnityEngine;
17
+ public class VRController : MonoBehaviour
18
+ {
19
+ private GameObject parent;
20
+ void Update()
21
+ {
22
+ var center = this.transform.localPosition;
23
+ // parentは親のGameObject
24
+ parent.transform.position = parent.transform.position + (this.transform.localPosition - center) * Time.deltaTime;
25
+ }
26
+ }
27
+ ```