マイロボット配置システム4




配置オブジェクトの向きを選択
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyBotBase : MonoBehaviour
{
private int num = 0;
void Update()
{
Vector3 pos = transform.position;
if(Input.GetKeyDown(KeyCode.LeftArrow))
{
transform.position = new Vector3(pos.x - 1, 0, pos.z);
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
transform.position = new Vector3(pos.x + 1, 0, pos.z);
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
transform.position = new Vector3(pos.x, 0, pos.z + 1);
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
transform.position = new Vector3(pos.x, 0, pos.z - 1);
}
// ★追加
if (Input.GetKeyDown(KeyCode.RightShift))
{
num += 1;
transform.rotation = Quaternion.Euler(0, 90 * num, 0);
}
}
}





配置オブジェクトの向きを選択
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyBotBase : MonoBehaviour
{
private int num = 0;
void Update()
{
Vector3 pos = transform.position;
if(Input.GetKeyDown(KeyCode.LeftArrow))
{
transform.position = new Vector3(pos.x - 1, 0, pos.z);
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
transform.position = new Vector3(pos.x + 1, 0, pos.z);
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
transform.position = new Vector3(pos.x, 0, pos.z + 1);
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
transform.position = new Vector3(pos.x, 0, pos.z - 1);
}
// ★追加
if (Input.GetKeyDown(KeyCode.RightShift))
{
num += 1;
transform.rotation = Quaternion.Euler(0, 90 * num, 0);
}
}
}

マイロボット配置システム4