Teachers open the door but You must enter by yourself.

Open Media Lab.
オープンメディアラボ

スペースシューター
Space Shooter

「Space Shooter」公式チュートリアル


【事前学習】前回学んだ機能を再確認しておきましょう。

Unityのチュートリアル「Space Shooter」では、アセットの素材を使ってプロジェクトを作成していく手順を学びます。Unityの多彩な機能を身につけて行ってください。

チュートリアルの進め方

公式ページにはチュートリアルがYouTubeの動画で示されています。本チュートリアルは残念ながら日本語の字幕もありませんが、英単語はUnityで用いられているものや比較的簡単なものですので英語の字幕を参考にして頑張ってください。YouTubeの設定(歯車のアイコン)をクリックして字幕を英語にしてください。また、余力のある方はYouTubeは再生速度を変更できますので、少し速度を落として英語のリスニング能力を養うのも良いでしょう。

Introduction to Space Shooter

最初の動画で本プロジェクトの一連の流れを把握します。

Game Setup, Player and Camera
Setting up the project

(注意事項)

Game Setup, Player and Camera
The player GameObject

(注意事項)

Game Setup, Player and Camera
Camera and lighting

(注意事項)

Game Setup, Player and Camera
Adding a background

(注意事項)

Game Setup, Player and Camera
Moving the player

Input Systemを使った PlayerController.cs の簡易版


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
	public float speed = 10.0f;
	public float tilt = 4.0f;
	private Rigidbody rb;

	void Start(){
		rb = gameObject.AddComponent<Rigidbody>();
	}

	private float moveHorizontal = 0f;
	private float moveVertical = 0f;

	void OnMove(InputValue movementValue){
		Vector2 movementVector = movementValue.Get<Vector2>();
		moveHorizontal = movementVector.x;
		moveVertical = movementVector.y;
	}

	void FixedUpdate(){
		Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
		rb.velocity = movement * speed;
		rb.position = new Vector3(
			Mathf.Clamp(rb.position.x, -6, 6),
			0.0f,
			Mathf.Clamp(rb.position.z, -4, 8)
		);
		rb.rotation = Quaternion.Euler(0.0f, 0.0f, rb.velocity.x * -tilt);
	}
}

【事後学習】本日学んだ機能を再確認しておきましょう。

This site is powered by Powered by MathJax