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

質問編集履歴

5

書式の改善

2020/09/02 05:27

投稿

Unimeshi
Unimeshi

スコア1

title CHANGED
File without changes
body CHANGED
@@ -112,6 +112,8 @@
112
112
  public Transform firePoint6;
113
113
  public Transform raderPoint;
114
114
 
115
+ public GameObject rader;
116
+ public GameObject lazer;
115
117
  void lockOn()
116
118
  {
117
119
  //ーーーーーーーーーーーーーーーーーーレーザー関連ーーーーーーーーーーーーーーーーーーーーーー//

4

書式の改善

2020/09/02 05:27

投稿

Unimeshi
Unimeshi

スコア1

title CHANGED
File without changes
body CHANGED
@@ -94,5 +94,65 @@
94
94
  }
95
95
  }
96
96
  ```
97
+ ###ボス(raderおよびlazer呼び出す側のスクリプト)
98
+ ######必要ないと思われるところは省略しました
99
+ ```C#
100
+ using System;
101
+ using System.Collections;
102
+ using System.Collections.Generic;
103
+ using System.ComponentModel.Design;
104
+ using System.Net;
105
+ using System.Security.Cryptography;
106
+ using System.Security.Permissions;
107
+ using System.Threading;
108
+ using UnityEngine;
97
109
 
110
+ public class boss : MonoBehaviour
111
+
112
+ public Transform firePoint6;
113
+ public Transform raderPoint;
114
+
115
+ void lockOn()
116
+ {
117
+ //ーーーーーーーーーーーーーーーーーーレーザー関連ーーーーーーーーーーーーーーーーーーーーーー//
118
+ Instantiate(rader, raderPoint.position, rader.transform.rotation);
119
+ Invoke("LaserBeam", 4f);
120
+ }
121
+
122
+ void LaserBeam()
123
+ {
124
+ Instantiate(lazer, firePoint6.position, lazer.transform.rotation);
125
+ }
126
+
127
+
128
+
129
+ private void OnTriggerEnter2D(Collider2D collision)
130
+ {
131
+ //collisionにぶつかった相手の情報が入っている:bullet,player
132
+ if (collision.CompareTag("Player") == true)
133
+ {
134
+ gameController.GameOver();
135
+ }
136
+ else if (collision.CompareTag("Bullet") == true)
137
+ {
138
+ int tmpPoint = BossLife;
139
+ tmpPoint = tmpPoint - 1;
140
+ BossLife = tmpPoint;
141
+
142
+ if (BossLife == 100)
143
+ {
144
+ InvokeRepeating("lockOn", 1f, 20f);
145
+
146
+ if (BossLife == 0)
147
+ {
148
+ Instantiate(explosion, transform.position, transform.rotation);
149
+ Destroy(gameObject);
150
+ Destroy(collision.gameObject);
151
+ gameController.AddScore();
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ ```
98
158
  なんとかして座標を取得できないのでしょうか。それとも、そもそもPrefabの座標は更新できないのでしょうか?

3

解答がつかなかったため

2020/09/02 04:12

投稿

Unimeshi
Unimeshi

スコア1

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,9 @@
1
1
  現在2Dシューティングゲームを制作しています。
2
2
  『数秒ほどプレイヤーを追跡し、一定時間後、座標を固定して、そこにレーザーを撃ち込む』というスクリプトを作りたいのですが、どうしてもProject上の座標(0, 0, 0)にレーザーが飛んで行ってしまいます。
3
+ ###実現したいこと
4
+
5
+ #####【プレイヤーObjectを追跡用オブジェクトが追跡=> 一定時間後、追跡用オブジェクトの座標を固定=>追跡用オブジェクトの座標にレーザーを撃ち込む】
6
+
3
7
  流れとしては、【プレイヤーObjectを追跡用オブジェクトが追跡=> 一定時間後、追跡用オブジェクトの座標を固定=>追跡用オブジェクトの座標にレーザーを撃ち込む】といった流れです。
4
8
 
5
9
  5時間くらい奮闘したのですが、一向に解決しなかったので質問させていただきました。

2

タイトルの変更

2020/09/01 16:47

投稿

Unimeshi
Unimeshi

スコア1

title CHANGED
@@ -1,1 +1,1 @@
1
- Prefabの座標が反映されな
1
+ 指定した座標にレーザーを撃ち込みた
body CHANGED
File without changes

1

タイトルの変更

2020/09/01 09:11

投稿

Unimeshi
Unimeshi

スコア1

title CHANGED
@@ -1,1 +1,1 @@
1
- Prefabの座標を取得し、そこにレーザーを撃ちた
1
+ Prefabの座標が反映されな
body CHANGED
File without changes