๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/์œ ๋‹ˆํ‹ฐ

์œ ๋‹ˆํ‹ฐ - ์บ๋ฆญํ„ฐ ์›€์ง์ด๊ธฐ ์• ๋‹ˆ๋ฉ”์ด์…˜

by Janger 2021. 11. 28.
728x90
๋ฐ˜์‘ํ˜•

์šฐ์„  ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ ์šฉ๋˜๋Š” ๋ชจ๋ธ์„ ๊ตฌํ•˜๊ณ  

 

Animator ํด๋”๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์„œ ๊ทธ ์•ˆ์— Animator Controller๋ฅผ ์ƒ์„ฑ 

 

 

 

ํŒŒ์ผ ์ด๋ฆ„์€ MainAnimator

 

 

 

ํŒŒ์ผ์„ ๋‘๋ฒˆ ํด๋ฆญํ•˜๋ฉด ํ™”๋ฉด์€ ์• ๋‹ˆ๋ฉ”์ด์…˜๋“ค์„ ์ปจํŠธ๋กคํ•  ์ˆ˜ ์žˆ๋Š” ์ปจํŠธ๋กค ์ฐฝ์„ ๋œจ๊ฒŒ ํ•œ๋‹ค. 

์ €๊ณณ์—๋‹ค ์—ฌ๋Ÿฌ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๊ฐ์ฒด๋“ค์„ ๋Œ์—ฌ ๋‹น๊ฒจ์„œ ์—ฐ๊ฒฐ์„ ์‹œ์ผœ์ฃผ๋ฉด ๋œ๋‹ค. 

 

์ ํ”„ ํ›„์— WAIT01 ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ž‘๋™ํ•˜๊ฒŒ ์—ฐ๊ฒฐํ•ด์คŒ

 

 

 

๊ทธ๋ฆฌ๊ณ  ๋‹ค์‹œ ์บ๋ฆญํ„ฐ ๋ชจ๋ธ์˜ Inspector์„ ํ™•์ธํ•ด Animator ์ปดํฌ๋„ŒํŠธ์— Controller๋ฅผ ์•„๊นŒ ์ƒ์„ฑํ•ด์„œ ์„ค์ •ํ•œ MainAnimator๋ฅผ ์ ์šฉ. 

 

 

 

์ด์ œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์จ์ค€๋‹ค. 

 

[Main Controller.cs]

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

public class MainController : MonoBehaviour
{
	public Animator animator;

    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        
    	if( Input.GetKeyDown(KeyCode.Space) ){
    		animator.Play("JUMP00", -1, 0);
    	}

    }
}

์ŠคํŽ˜์ด์Šค๋ฐ”๋ฅผ ๋ˆ„๋ฅด๋ฉด animator.Play๋ฅผ ์ž‘๋™์‹œ์ผœ "JUMP00"์ด๋ผ๋Š” ๋™์ž‘์„ ํ•˜๋„๋ก ์‹œํ‚จ๋‹ค. 

 

 

 

์ถœ์ฒ˜: 

https://www.youtube.com/watch?v=8PO48QvedV8&ab_channel=%EB%8F%99%EB%B9%88%EB%82%98 

 

728x90
๋ฐ˜์‘ํ˜•