質問編集履歴
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
4
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
### 前提・実現したいこと
|
4
4
|
|
5
|
+
現在、2dのアクションゲームを作っています。アクションゲームのキャラに
|
5
|
-
リンクのような剣の振り方を
|
6
|
+
リンクのような剣の振り方をさせたくて、剣をプレイヤーを軸にして回転がさせたいです。
|
6
|
-
|
7
|
+
親子関係にすると親が軸になるというのをみたので
|
7
8
|
prefab.transform.parent = transformでスクリプトで親子関係を作りたいのですがうまくいきません
|
8
|
-
エラーによるとスクリプトによるお
|
9
|
+
エラーによるとスクリプトによるおや子関係は無効化されているみたいです。
|
9
10
|
|
10
11
|
### 発生している問題・エラーメッセージ
|
11
12
|
|
3
sy式の改善
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[Unity]
|
1
|
+
[Unity]transform.parentについて
|
test
CHANGED
File without changes
|
2
書式の改善
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[Unity]
|
1
|
+
[Unity]回転軸の変更方法がわからない
|
test
CHANGED
@@ -3,43 +3,52 @@
|
|
3
3
|
### 前提・実現したいこと
|
4
4
|
|
5
5
|
リンクのような剣の振り方を実現したくて
|
6
|
-
剣をプレイヤーを支点にする回転がさせたいです。
|
6
|
+
剣をプレイヤーを支点にする回転がさせたいです。親子関係にすると親が軸になるというのをみたので
|
7
|
-
|
7
|
+
prefab.transform.parent = transformでスクリプトで親子関係を作りたいのですがうまくいきません
|
8
|
+
エラーによるとスクリプトによるおけ子関係は無効化されているみたいです。
|
8
9
|
|
9
10
|
### 発生している問題・エラーメッセージ
|
10
11
|
|
11
12
|
```
|
13
|
+
Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption (GameObject: 'Sword').
|
12
|
-
|
14
|
+
UnityEngine.Transform:set_parent (UnityEngine.Transform)
|
13
15
|
```
|
14
16
|
|
15
17
|
### 該当のソースコード
|
16
18
|
|
17
19
|
```ここに言語名を入力
|
20
|
+
|
18
|
-
public
|
21
|
+
public GameObject swordPrefab;
|
22
|
+
|
19
|
-
public GameObject player;
|
23
|
+
public GameObject playerObject;
|
20
24
|
Rigidbody2D rb;
|
21
25
|
// Start is called before the first frame update
|
22
26
|
void Start()
|
23
27
|
{
|
24
28
|
rb = GetComponent<Rigidbody2D>();
|
25
|
-
|
29
|
+
|
26
|
-
rb.centerOfMass = new Vector3(0,0,1);
|
27
30
|
}
|
28
31
|
|
29
32
|
// Update is called once per frame
|
30
33
|
void Update()
|
31
34
|
{
|
32
35
|
|
33
|
-
}
|
36
|
+
}
|
34
37
|
|
35
|
-
|
38
|
+
void FixedUpdate(){
|
36
|
-
rb.angularVelocity = new Vector3(0,0,speed);
|
37
39
|
|
40
|
+
|
41
|
+
|
42
|
+
if(Input.GetKey(KeyCode.Space)){
|
43
|
+
Instantiate(swordPrefab, transform.position, Quaternion.Euler(0,0,-40));
|
44
|
+
swordPrefab.transform.parent = transform;
|
38
|
-
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
39
48
|
```
|
40
49
|
|
41
50
|
### 試したこと
|
42
|
-
|
51
|
+
SetParentにしてみたり(今回のやり方では相応しくない感じです
|
43
52
|
|
44
53
|
### 補足情報(FW/ツールのバージョンなど)
|
45
54
|
|
1
五時
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,6 @@
|
|
40
40
|
|
41
41
|
### 試したこと
|
42
42
|
|
43
|
-
Transform.rotateで回転させたりしましたが、今知りたいのはangularVelocityでの回転方法です。
|
44
43
|
|
45
44
|
### 補足情報(FW/ツールのバージョンなど)
|
46
45
|
|