今月のコード
Unity/C#研究中です。
なかなか難しいです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeMove : MonoBehaviour
{
void Update()
{
float moveX = Input.GetAxis(“Horizontal”) * Time.deltaTime * 5.0f;
float moveZ = Input.GetAxis(“Vertical”) * Time.deltaTime * 5.0f;
transform.position = new Vector3 (
transform.position.x + moveX, 0, transform.position.z + moveZ);
if (Input.GetKey(KeyCode.RightArrow))
{
transform.rotation = Quaternion.Euler(0,0,–20);
}
else if (Input.GetKey(KeyCode.LeftArrow))
{
transform.rotation = Quaternion.Euler(0,0,20);
}
else if (Input.GetKey(KeyCode.UpArrow))
{
transform.rotation = Quaternion.Euler(20,0,0);
}
else if (Input.GetKey(KeyCode.DownArrow))
{
transform.rotation = Quaternion.Euler(–20,0,0);
}
else
{
transform.rotation = Quaternion.Euler(0,0,0);
}
}
}
The following two tabs change content below.