質問編集履歴
3
コード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -351,4 +351,36 @@
|
|
351
351
|
コード
|
352
352
|
```
|
353
353
|
|
354
|
+
```
|
355
|
+
using System.Collections;
|
356
|
+
using System.Collections.Generic;
|
357
|
+
using UnityEngine;
|
358
|
+
|
359
|
+
public class Circle : MonoBehaviour
|
360
|
+
{
|
361
|
+
// Start is called before the first frame update
|
362
|
+
void Start()
|
363
|
+
{
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
// Update is called once per frame
|
368
|
+
void Update()
|
369
|
+
{
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
private void OnCollisionEnter2D(Collision2D collision)
|
374
|
+
{
|
375
|
+
if (collision.gameObject.tag == "Square")
|
376
|
+
{
|
377
|
+
Debug.Log("サークルとスクウェアが接触しました");
|
378
|
+
Debug.Log( collision);
|
379
|
+
Debug.Log( gameObject);
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
コード
|
384
|
+
```
|
385
|
+
|
354
386
|

|
2
InvokeがUpdate内で動作するコード
title
CHANGED
File without changes
|
body
CHANGED
@@ -260,4 +260,95 @@
|
|
260
260
|
コード
|
261
261
|
```
|
262
262
|
|
263
|
-

|
263
|
+

|
264
|
+
|
265
|
+
|
266
|
+
```
|
267
|
+
|
268
|
+
|
269
|
+
void Start()
|
270
|
+
{
|
271
|
+
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
void Update()
|
277
|
+
{
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
if (Input.GetKey(KeyCode.Space))
|
282
|
+
{
|
283
|
+
samp.Move();
|
284
|
+
// Debug.Log(samp);
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
Invoke("Vanish2", 1.5f);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
private void Vanish2()
|
293
|
+
{
|
294
|
+
samp.Vanish();
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
コード
|
299
|
+
```
|
300
|
+
```
|
301
|
+
using System.Collections;
|
302
|
+
using System.Collections.Generic;
|
303
|
+
using UnityEngine;
|
304
|
+
|
305
|
+
public class Sample : MonoBehaviour
|
306
|
+
{
|
307
|
+
public float xspeed;
|
308
|
+
public float yspeed;
|
309
|
+
|
310
|
+
|
311
|
+
public GameObject squ;
|
312
|
+
public GameObject cir;
|
313
|
+
public GameObject cup;
|
314
|
+
|
315
|
+
Rigidbody2D rigidcir;
|
316
|
+
Rigidbody2D rigidcup;
|
317
|
+
Rigidbody2D rigidsqu;
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
private void Start()
|
322
|
+
{
|
323
|
+
rigidcir = cir.GetComponent<Rigidbody2D>();
|
324
|
+
rigidsqu = squ.GetComponent<Rigidbody2D>();
|
325
|
+
rigidcup = cup.GetComponent<Rigidbody2D>();
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
private void Update()
|
330
|
+
{
|
331
|
+
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
public void Move()//これを呼び出したい
|
336
|
+
{
|
337
|
+
cir.transform.Translate(-xspeed, -yspeed, 0);
|
338
|
+
squ.transform.Translate(-xspeed, yspeed, 0);
|
339
|
+
|
340
|
+
|
341
|
+
// Debug.Log(squ);
|
342
|
+
}
|
343
|
+
public void Vanish()
|
344
|
+
{
|
345
|
+
cup.SetActive(false);
|
346
|
+
}
|
347
|
+
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
コード
|
352
|
+
```
|
353
|
+
|
354
|
+

|
1
Switch発動のオブジェクトに乗ってしまう図を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -258,4 +258,6 @@
|
|
258
258
|
}
|
259
259
|
|
260
260
|
コード
|
261
|
-
```
|
261
|
+
```
|
262
|
+
|
263
|
+

|