質問編集履歴

1

新たに試したソースコードの記載

2018/07/25 09:48

投稿

Asyet_
Asyet_

スコア8

test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,120 @@
58
58
 
59
59
 
60
60
 
61
+ ### 追加:新たに試したソースコード
62
+
63
+
64
+
65
+ ```C#
66
+
67
+ using System.Collections;
68
+
69
+ using System.Collections.Generic;
70
+
71
+ using UnityEngine;
72
+
73
+
74
+
75
+ public class PfTimeInsta : MonoBehaviour {
76
+
77
+
78
+
79
+ // 生成したいPrefab
80
+
81
+ public GameObject UpBullet;
82
+
83
+
84
+
85
+ public Transform motherTf;
86
+
87
+
88
+
89
+ bool Shootstate = true;
90
+
91
+
92
+
93
+ public float timeOut = 3;
94
+
95
+ private float timeTrigger;
96
+
97
+
98
+
99
+
100
+
101
+ void Start()
102
+
103
+ {
104
+
105
+
106
+
107
+ }
108
+
109
+
110
+
111
+ void Update()
112
+
113
+ {
114
+
115
+ if (Shootstate == true)
116
+
117
+ {
118
+
119
+
120
+
121
+ if (Time.time > timeTrigger)
122
+
123
+ {
124
+
125
+
126
+
127
+ Instantiate(UpBullet);
128
+
129
+ UpBullet.transform.position = motherTf.position;
130
+
131
+
132
+
133
+ timeTrigger = Time.time + timeOut;
134
+
135
+
136
+
137
+ }
138
+
139
+ }
140
+
141
+ }
142
+
143
+
144
+
145
+ public void StopShoot()
146
+
147
+ {
148
+
149
+ Shootstate = false;
150
+
151
+ }
152
+
153
+
154
+
155
+ public void StartShoot()
156
+
157
+ {
158
+
159
+ if (Shootstate == false)
160
+
161
+ {
162
+
163
+ Shootstate = true;
164
+
165
+ }
166
+
167
+ }
168
+
169
+ }
170
+
171
+ ```
172
+
173
+
174
+
61
175
  ### 試したこと
62
176
 
63
177