Skip to content

Instantly share code, notes, and snippets.

@coding-youtuber
Created May 3, 2020 02:32
Show Gist options
  • Save coding-youtuber/d8d520578c3889e170a93af793099937 to your computer and use it in GitHub Desktop.
Save coding-youtuber/d8d520578c3889e170a93af793099937 to your computer and use it in GitHub Desktop.
UnityでCubeを矢印キーで動かす
using UnityEngine;
public class CubeMovement : MonoBehaviour
{
public float moveSpeed;
// Start is called before the first frame update
void Start()
{
// moveSpeed = 1f;
}
// Update is called once per frame
void Update()
{
// Debug.Log(Input.GetAxis("Horizontal"));
// Debug.Log(Input.GetAxis("Vertical"));
transform.Translate(Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime, 0f, Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment