//tips
stage作成
//cubeで地表に三角錐を作成
Cubeの位置頂点を中心とした三角錐を作成する。
Rotationをx:30、y:45にして、cubeを回転させた後、地表に沈める。
露出部分が錐になったら大きさをscaleで微調整する。
//stage制約条件
Stagehardを作るにあたって下記の制約条件を設けた。
・Stagehardの制約条件を最低一つは25手以内のゴール手順があること
・最低2種類以上のゴール手順があること
とした。
シーンごとにmapを作成し、mapに手順を書き込む形で製作する。enermyの位置はplayer手順とenemy行動パターン数から計算し、現在位置を割り出す。
プレイで手順を検証し、優しすぎたらenemyなどを追加する。
//instantiateでcrone作成
instantiate関数を使用してcountに対応してcroneを作成する。
Instantiate関数は生成オブジェクト、座標、向きを指定してクローンを生成できる。
Instantiate(obj, this.transform.position, Quaternion.identity);
向きがオリジナルと同じでいい場合はQuaternion.identityにしておけば問題ない。
Instantiate(originObject, new Vector3(0.0f, -0.5f, 1.0f), Quaternion.identity);
これはoriginObjectを座標Vector3(0.0f, -0.5f, 1.0f)にオリジナルと同じ向きでクローンを生成するということである。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyCrone : MonoBehaviour
{
private int count = 0;
public GameObject originObject; //オリジナルのオブジェクト
void Update()
{
if (Input.anyKeyDown)
{
count++;
if (count == 3)
{
Instantiate(originObject, new Vector3(4.0f, -0.5f, 9.0f), Quaternion.identity);
}
if (count == 6)
{
Instantiate(originObject, new Vector3(5.0f, -0.5f, 9.0f), Quaternion.identity);
}
if (count == 9)
{
Instantiate(originObject, new Vector3( 6.0f, -0.5f, 9.0f), Quaternion.identity);
}
if (count == 12)
{
Instantiate(originObject, new Vector3(7.0f, -0.5f, 9.0f), Quaternion.identity);
}
if (count == 15)
{
Instantiate(originObject, new Vector3(8.0f, -0.5f, 9.0f), Quaternion.identity);
}
}
}
}
Quaternionを操作したい場合は下記のように変数を作成して代入する形にする。
Quaternion q = Quaternion.Euler(0f, 270.0f, 0.0f);
Instantiate(originObject, new Vector3(4.0f, -0.5f, 0.0f), q);