)using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sword_Man : MonoBehaviour
{
ย ย // Start is called before the first frame update
ย ย Animator animator;
ย ย void Start()
ย ย {
ย ย ย ย transform.position = new Vector3(0, 0, 0);
ย ย ย ย animator = GetComponent<Animator>();
ย ย }
ย ย // Update is called once per frame
ย ย void Update()
ย ย {
ย ย ย ย float h = Input.GetAxis("Horizontal");
ย ย ย ย if (h > 0)
ย ย ย ย {
ย ย ย ย ย ย transform.localScale = new Vector3(-1, 1, 1);
ย ย ย ย ย ย animator.SetBool("moving", true);
ย ย ย ย }
ย ย ย ย else if (h < 0)
ย ย ย ย {
ย ย ย ย ย ย transform.localScale = new Vector3(1, 1, 1);
ย ย ย ย ย ย animator.SetBool("moving", true);
ย ย ย ย }
ย ย ย ย else animator.SetBool("moving", false);
ย ย ย ย transform.Translate(new Vector3(h, 0, 0) * Time.deltaTime);
ย ย }
}
์ต์ข ๋ณด์ค๋๋๋๊ณ ์ข๋ค
์ง๊ธ์๋นํ์ฌ๊ฐํ์ํฉ์ ๋๋ค
ใ ใ ใ ใ ใ ใ
์ ๋๋ฉ์ด์ ์ชฝ์ ๋ฌธ์ ์๋๋ณธ๋ฐ?
์ ๋๋ฉ์ด์ ์ ์ ๊ณตํ๋ ์๋ฃ๊ทธ๋๋ก ๊ฐ์ ธ๋ค ์ฌ์ฉํ๋๋ฐ ํ์ผ ๋ค์ ๋ค์ด๋ฐ์์ ์ ์ฉํด๋ณด๊ฒ ์ต๋๋ค
์ ๋๋ฉ์ด์ ์ค์ ์ ํจ ๋ด๋ด์ผ๋ ๊ฑฐ๊ฐ์๋ฐ
๋ ์ด ์ค์ ๊ด์ฐฎ์๊ฑธ.
transform.Translate(new Vector3(h, 0, 0) * Time.deltaTime); ์ฌ๊ธฐ์ {} ์ด๊ฑฐ ์์ด์ ๊ทธ๋ฐ๊ฑฐ ์๋?