using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
public float speed = 5f;
void Update()
{
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
Vector3 dir = Vector3.right * h + Vector3.up * v;
//dir의 크기가 1이 아닌 경우가 있음 -> 크기를 1로 만들 때 정규화
dir.Normalize();
transform.position += dir * speed * Time.deltaTime;
}
}
'Unity > Team Project' 카테고리의 다른 글
유니티 2인 프로젝트 03.08 ~ 03.28 (0) | 2022.03.28 |
---|---|
프로젝트 1-2 플레이어 대쉬 (0) | 2022.03.15 |
Instantiate (0) | 2021.08.22 |
Scroll View 처음 부분부터 보이게 하기 (0) | 2021.08.20 |
유니티 자동 로그인 및 닉네임 생성창 (0) | 2021.07.26 |