-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player_Plus.cs
39 lines (32 loc) · 1.11 KB
/
Player_Plus.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float speed;
float hAxis;
float vAxis;
bool wDown;
Animator anim;
Vector3 moveVec;
void Start()
{
anim = GetComponentInChildren<Animator>();
}
// Update is called once per frame
void Update()
{
hAxis = Input.GetAxisRaw("Horizontal");
vAxis = Input.GetAxisRaw("Vertical");
//간단하게 hAxis, vAxis는 하나의 수직선이라고 보면 된다.
//이 상황에서는 Horizontal과 Vertical을 합쳐 x축과 z축을 만듬.
//Horizontal의 키보드 입력은 left와 right, Vertical은 up,down이다.
wDown = Input.GetButton("Walk");
moveVec = new Vector3(hAxis, 0, vAxis).normalized;
//normalized는 대각선으로 갈시 빨라지는 것을 보정해주는 것.
transform.position += moveVec * speed * Time.deltaTime;
anim.SetBool("isRun", moveVec != Vector3.zero);
anim.SetBool("isWalk", wDown);
// set Animation Setting
}
}