using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChangeAnim : MonoBehaviour
{
    public string upAnime;  // 위쪽방향 애니메이션 클립이 저장되는 변수
    public string downAnime;
    public string leftAnime;
    public string rightAnime;

    string nowMode;     // 방향키눌렀을 때 그 방향의 애니메이션클립을 저장해두는 변수

    Animator anim;      // 애니메이터 컴포넌트형 변수선언

    void Start()
    {
        anim = GetComponent<Animator>();

        nowMode = downAnime;
    }
    void Update()
    {
        if (Input.GetKey("right"))
        {
            nowMode = rightAnime;
        }
        if (Input.GetKey("left"))
        {
            nowMode = leftAnime;
        }
        if (Input.GetKey("up"))
        {
            nowMode = upAnime;
        }
        if (Input.GetKey("down"))
        {
            nowMode = downAnime;
        }
    }
    void FixedUpdate()
    {
        anim.Play(nowMode);
    }
}

'----------고1---------- > 게임엔진' 카테고리의 다른 글

[고1 게임엔진] 10 - (2)  (2) 2023.10.16
[고1 게임엔진] 10 - (1)  (0) 2023.10.11
[고1 게임엔진] 09 - (5)  (2) 2023.09.20
[고1 게임엔진] 09 - (4)  (0) 2023.09.18
[고1 게임엔진] 09 - (3)  (0) 2023.09.13