-
1. Unity 설치
생략
2. Unity 기본 이해
메뉴구조
Project
새 Project, 3d 동작구조
Script
Scene저장
3. UnityChan 설치
2020/11/08 - Unity - UnityChan 사용준비
4. UnityChan Import
2020/11/08 - Unity - UnityChan 사용준비
5. UnityChan Model사용
2020/11/16 - Unity - UnityChan Model Improt
6. UnityChan 이동 처리
Uc1 Script만들어 내용을 아래와 같이 수정한다.
... public class Uc1 : MonoBehaviour { public Animator mA; ... void Update() { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); transform.position += new Vector3(h * Time.deltaTime, 0, v * Time.deltaTime); } }
unitychan model에 적용하고, MA를 Model자신인 unitychan으로 지정한다
실행을 해보면 방향키로 앞뒤 좌우 이동이 가능하다.
아직 Animator mA는 사용하지 않는다, 이어지는 Animation처리에서 반드시 필요하다.
7. UnityChan AnimatorControler
2020/11/11 - Unity - AnimatorController (UnityChan으로 Animation)
8. UnityChan 이동 적용
//... public class Uc1 : MonoBehaviour { public Animator mA; //... void Update() { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); transform.position += new Vector3(h * Time.deltaTime, 0, v * Time.deltaTime); mA.SetFloat("h", h); mA.SetFloat("v", v); } }
2020/11/16 - Unity - UnityChan Transition(Animation)
여기까지하면 앞뒤좌우 이동은 되지만,
캐릭터가 이동방향으로 회전하지 않는다.
9. UnityChan 방향 전환
transform.Rotate (0, h * Time.deltaTime*90, 0);
을 추가하면 캐릭터가 옆으로 회전은 하지만,
회전한 방향으로 이동하지 않고 기존 전후진 방향으로만 이동한다.
void Update() { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); transform.Rotate (0, h * Time.deltaTime*90, 0); transform.position += transform.TransformDirection (0, 0, v * Time.deltaTime); mA.SetFloat("h", h); mA.SetFloat("v", v); }
이제 캐릭터는 좌우 회전한 방향으로 정상적인 전후진이 가능해 진다.
10. UnityChan 점프
animation에 unitychan_JUMP00.fbx를 추가하고 Wait로 복귀되도록 연결한다.
Jump Animation전환 코드 추가
void Update() { if(Input.GetKeyDown(KeyCode.Space)) { mA.Play("JUMP00"); } //... }
'Unity' 카테고리의 다른 글
Unity - Material (0) 2021.03.18 Unity - instantiate (GameObject 생성 함수) (0) 2020.11.17 Unity - UnityChan Transition(Animation) (0) 2020.11.16 Unity - UnityChan Model Improt (0) 2020.11.16 Unity - Transform (0) 2020.11.14 Unity - AnimationClipInfo 얻기 (0) 2020.11.11 Unity - AnimationEvent (0) 2020.11.11 Unity - OnCollisionEnter OnCollisionStay OnCollisionExit (0) 2020.11.11