ARシューティングゲームの開発
![37c8ce94 7a3e 41b2 b07c 78e0319062e5](https://codegenius.org/uploads/slide/image/8122/37c8ce94-7a3e-41b2-b07c-78e0319062e5.jpeg)
![Be8c4133 22eb 4bd6 b976 0d30a8142b65](https://codegenius.org/uploads/slide/image/8123/be8c4133-22eb-4bd6-b976-0d30a8142b65.jpeg)
![2eb9d60c ccea 4099 bd72 06280cc72ca1](https://codegenius.org/uploads/slide/image/8124/2eb9d60c-ccea-4099-bd72-06280cc72ca1.jpeg)
![Ccf03de3 f551 41a5 9ea0 be8fec723365](https://codegenius.org/uploads/slide/image/8125/ccf03de3-f551-41a5-9ea0-be8fec723365.jpeg)
![8c29f08c a44b 4722 94cb c3426b50ca89](https://codegenius.org/uploads/slide/image/8126/8c29f08c-a44b-4722-94cb-c3426b50ca89.jpeg)
敵を動かす(直線)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove : MonoBehaviour
{
void Update()
{
transform.Translate(new Vector3(0, 0.1f, 0) * Time.deltaTime, Space.World);
}
}
![127ca12d 3d20 485d 94ec e81dbb5a5c11](https://codegenius.org/uploads/slide/image/8127/127ca12d-3d20-485d-94ec-e81dbb5a5c11.jpeg)
![E6e82628 13e1 4046 bf68 f695b82b5ca3](https://codegenius.org/uploads/slide/image/8128/e6e82628-13e1-4046-bf68-f695b82b5ca3.jpeg)
![4d35eca2 4571 49d2 8b74 ad521f482438](https://codegenius.org/uploads/slide/image/8129/4d35eca2-4571-49d2-8b74-ad521f482438.jpeg)
敵を動かす(L字型)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove2 : MonoBehaviour
{
private float x;
private float z;
private float speed;
void Start()
{
StartCoroutine(MoveL());
}
void Update()
{
transform.Translate(new Vector3(x, 0, z) * speed * Time.deltaTime, Space.World);
}
// 敵が途中で右方向に移動
private IEnumerator MoveL()
{
// 最初はZ方向に移動
x = 0;
z = -0.1f;
speed = 1;
// 2秒経過後に
yield return new WaitForSeconds(2f);
// 右方向(X方向)に移動
x = 0.1f;
z = 0;
speed = 1.2f; // スピードも少しアップ
}
}
![Efd5a91e 73d1 4913 ae7e e60e4ace8a5b](https://codegenius.org/uploads/slide/image/8130/efd5a91e-73d1-4913-ae7e-e60e4ace8a5b.jpeg)
![25b57016 5484 4f9d 8e3d 4311b76ad820](https://codegenius.org/uploads/slide/image/8131/25b57016-5484-4f9d-8e3d-4311b76ad820.jpeg)
![A6f7d591 9fa0 448c bd85 b76b0ca5d9bc](https://codegenius.org/uploads/slide/image/8132/a6f7d591-9fa0-448c-bd85-b76b0ca5d9bc.jpeg)
敵を動かす(上下往復)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove3 : MonoBehaviour
{
private float y;
private float z;
private float speed;
private void Start()
{
StartCoroutine(DMove());
}
private void Update()
{
transform.Translate(new Vector3(0, y, z) * speed * Time.deltaTime, Space.World);
}
private IEnumerator DMove()
{
// 繰り返し文の追加(ポイント)
for (int i = 0; i < 3; i++)
{
y = 0.1f;
z = -0.1f;
speed = 1f;
yield return new WaitForSeconds(1f);
y = -0.1f;
z = -0.1f;
speed = 1f;
yield return new WaitForSeconds(1f);
}
}
}
![Ea9deb4f ec59 4baf a249 ed14dd7fc902](https://codegenius.org/uploads/slide/image/8133/ea9deb4f-ec59-4baf-a249-ed14dd7fc902.jpeg)
![57f33994 8092 403e a149 81ce02f9f46e](https://codegenius.org/uploads/slide/image/8134/57f33994-8092-403e-a149-81ce02f9f46e.jpeg)
【2022版】AR_Project(全9回)
1 | キャラクターをAR鑑賞する |
2 | ★チャレンジ課題 |
3 | ARシューティングゲームの開発 |
4 | ★チャレンジ課題 |
5 | 敵の製造装置を作る |
6 | 敵を破壊する |
7 | オリジナルのカーソルを作成する |
8 | カウンターを作成する |
9 | ★チャレンジ課題 |
![37c8ce94 7a3e 41b2 b07c 78e0319062e5](https://codegenius.org/uploads/slide/image/8122/37c8ce94-7a3e-41b2-b07c-78e0319062e5.jpeg)
![Be8c4133 22eb 4bd6 b976 0d30a8142b65](https://codegenius.org/uploads/slide/image/8123/be8c4133-22eb-4bd6-b976-0d30a8142b65.jpeg)
![2eb9d60c ccea 4099 bd72 06280cc72ca1](https://codegenius.org/uploads/slide/image/8124/2eb9d60c-ccea-4099-bd72-06280cc72ca1.jpeg)
![Ccf03de3 f551 41a5 9ea0 be8fec723365](https://codegenius.org/uploads/slide/image/8125/ccf03de3-f551-41a5-9ea0-be8fec723365.jpeg)
![8c29f08c a44b 4722 94cb c3426b50ca89](https://codegenius.org/uploads/slide/image/8126/8c29f08c-a44b-4722-94cb-c3426b50ca89.jpeg)
敵を動かす(直線)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove : MonoBehaviour
{
void Update()
{
transform.Translate(new Vector3(0, 0.1f, 0) * Time.deltaTime, Space.World);
}
}
![127ca12d 3d20 485d 94ec e81dbb5a5c11](https://codegenius.org/uploads/slide/image/8127/127ca12d-3d20-485d-94ec-e81dbb5a5c11.jpeg)
![E6e82628 13e1 4046 bf68 f695b82b5ca3](https://codegenius.org/uploads/slide/image/8128/e6e82628-13e1-4046-bf68-f695b82b5ca3.jpeg)
![4d35eca2 4571 49d2 8b74 ad521f482438](https://codegenius.org/uploads/slide/image/8129/4d35eca2-4571-49d2-8b74-ad521f482438.jpeg)
敵を動かす(L字型)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove2 : MonoBehaviour
{
private float x;
private float z;
private float speed;
void Start()
{
StartCoroutine(MoveL());
}
void Update()
{
transform.Translate(new Vector3(x, 0, z) * speed * Time.deltaTime, Space.World);
}
// 敵が途中で右方向に移動
private IEnumerator MoveL()
{
// 最初はZ方向に移動
x = 0;
z = -0.1f;
speed = 1;
// 2秒経過後に
yield return new WaitForSeconds(2f);
// 右方向(X方向)に移動
x = 0.1f;
z = 0;
speed = 1.2f; // スピードも少しアップ
}
}
![Efd5a91e 73d1 4913 ae7e e60e4ace8a5b](https://codegenius.org/uploads/slide/image/8130/efd5a91e-73d1-4913-ae7e-e60e4ace8a5b.jpeg)
![25b57016 5484 4f9d 8e3d 4311b76ad820](https://codegenius.org/uploads/slide/image/8131/25b57016-5484-4f9d-8e3d-4311b76ad820.jpeg)
![A6f7d591 9fa0 448c bd85 b76b0ca5d9bc](https://codegenius.org/uploads/slide/image/8132/a6f7d591-9fa0-448c-bd85-b76b0ca5d9bc.jpeg)
敵を動かす(上下往復)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMove3 : MonoBehaviour
{
private float y;
private float z;
private float speed;
private void Start()
{
StartCoroutine(DMove());
}
private void Update()
{
transform.Translate(new Vector3(0, y, z) * speed * Time.deltaTime, Space.World);
}
private IEnumerator DMove()
{
// 繰り返し文の追加(ポイント)
for (int i = 0; i < 3; i++)
{
y = 0.1f;
z = -0.1f;
speed = 1f;
yield return new WaitForSeconds(1f);
y = -0.1f;
z = -0.1f;
speed = 1f;
yield return new WaitForSeconds(1f);
}
}
}
![Ea9deb4f ec59 4baf a249 ed14dd7fc902](https://codegenius.org/uploads/slide/image/8133/ea9deb4f-ec59-4baf-a249-ed14dd7fc902.jpeg)
![57f33994 8092 403e a149 81ce02f9f46e](https://codegenius.org/uploads/slide/image/8134/57f33994-8092-403e-a149-81ce02f9f46e.jpeg)
ARシューティングゲームの開発