7dec9e36ebd518986abce89540887d651b


2cb99e36ebd518986abce8954087746420


29b9d468f5dc3f8650bbd58b36857668e62d




์ผ๋‹จ ์ฝ”๋”ฉ 1๋„ ๋ชจ๋ฅด๋Š”๋ฐ chat gpt๋ฏฟ๊ณ  ๋„์ „ํ•ด๋ณผ๋ผ๊ณ  ํ•œ๋‹ค..


์ €๊ธฐ ์„ค๋ช…๋œ๊ฒŒ ๋งž๋Š” ๋ง์ธ๊ฑฐ๋ƒ..?


์ผ๋‹จ ์Šคํ”„๋ผ์ดํŠธ๋ž‘ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ด๋ผ๊ธธ๋ž˜ ๋ฌผ์–ด๋ดค๋Š”๋ฐ ์ฝ”๋“œ๊ฐ™์€๊ฑธ ์ฃผ๋„ค




using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class PlayerController : MonoBehaviour

{

ย  ย  public float speed = 5.0f;


ย  ย  private Animator animator;


ย  ย  void Start()

ย  ย  {

ย  ย  ย  ย  animator = GetComponent<Animator>();

ย  ย  }


ย  ย  void Update()

ย  ย  {

ย  ย  ย  ย  float horizontalInput = Input.GetAxis("Horizontal");

ย  ย  ย  ย  float verticalInput = Input.GetAxis("Vertical");


ย  ย  ย  ย  Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);

ย  ย  ย  ย  transform.position += direction * speed * Time.deltaTime;


ย  ย  ย  ย  if (direction != Vector3.zero)

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  animator.SetBool("isWalking", true);

ย  ย  ย  ย  ย  ย  animator.SetFloat("x", direction.x);

ย  ย  ย  ย  ย  ย  animator.SetFloat("y", direction.y);

ย  ย  ย  ย  }

ย  ย  ย  ย  else

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  animator.SetBool("isWalking", false);

ย  ย  ย  ย  }

ย  ย  }

}

์†”์งํžˆ ๋ญ๊ฐ€ ๋ญ”์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค..