유니티에서 우선 플레이어를 움직이는 스크립트
처음에
비행 게임이나 FPS로 플레이어를 움직이는 스크립트를 썼습니다. 플레이어의 이동 방법을 모르는 사람은 필견입니다!
(이것은 mac에서 개발한다고 가정합니다)
아래 준비









이제 아래 준비는 OK입니다.
스크립트
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_controller : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.UpArrow))
{
transform.position += new Vector3(0,0,0.1f);
}
if (Input.GetKey(KeyCode.DownArrow))
{
transform.position += new Vector3(0,0,-0.1f);
}
if (Input.GetKey(KeyCode.RightArrow))
{
transform.position += new Vector3(0.1f,0,0);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.position += new Vector3(-0.1f,0,0);
}
}
}
열린 프로그램의 내용을 모두 삭제하고 위의 스크립트를 복사하여 명령 S로 저장. unity로 돌아가서 이 스크립트를 Cube에 드래그 앤 드롭을 한다. 이것으로 위의 삼각의 버튼을 누르면 종료입니다.
큐브에 스크립트를 넣을 수 없다면 스크립트를 마우스 오른쪽 버튼으로 클릭 -> Remame을 눌러 'Player_controller'라고 넣어보십시오!
마지막으로
끝까지 봐 주셔서 감사합니다. Qiita는 방금 시작했기 때문에 잘못되었다면 언제든지 지적하십시오! 잘 부탁드립니다.
Reference
이 문제에 관하여(유니티에서 우선 플레이어를 움직이는 스크립트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/lot-uni/items/3e4b4f6fc397dd9ba260
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_controller : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.UpArrow))
{
transform.position += new Vector3(0,0,0.1f);
}
if (Input.GetKey(KeyCode.DownArrow))
{
transform.position += new Vector3(0,0,-0.1f);
}
if (Input.GetKey(KeyCode.RightArrow))
{
transform.position += new Vector3(0.1f,0,0);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.position += new Vector3(-0.1f,0,0);
}
}
}
끝까지 봐 주셔서 감사합니다. Qiita는 방금 시작했기 때문에 잘못되었다면 언제든지 지적하십시오! 잘 부탁드립니다.
Reference
이 문제에 관하여(유니티에서 우선 플레이어를 움직이는 스크립트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/lot-uni/items/3e4b4f6fc397dd9ba260텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)