유니티 프로젝트/Team Project1 - Fall Guys
폴가이즈 _ 3D 모델 / 애니메이션 (참고)
SUGI_
2022. 7. 12. 23:35
https://chameleonstudio.tistory.com/26
유니티 KeyCode 종류 알아보기
f해당 티스토리 페이지는 필자가 유니티 C# 개발을 하면서 학습한 내용들을 기록하고 공유하는 페이지입니다 ! - 틀린 부분이 있거나, 수정된 부분이 있다면 댓글로 알려주세요 ! - 해당 내용을
chameleonstudio.tistory.com
- 우리가 원하는 타이밍에 애니메이션 전환
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LHS_PlayerController : MonoBehaviour
{
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
animator.Play("Dance01");
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
animator.Play("Dance02");
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
animator.Play("Victory01");
}
}
}
- 상태 전의를 이용한 애니메이션 전환 (Transition)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LHS_PlayerController : MonoBehaviour
{
private Animator animator;
private void Awake()
{
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
Expression();
Run();
}
void Expression()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
animator.Play("Dance01");
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
animator.Play("Dance02");
}
else if (Input.GetKeyDown(KeyCode.Alpha3))
{
animator.Play("Victory01");
}
}
void Run()
{
if(Input.GetKeyDown(KeyCode.Alpha4))
{
animator.SetFloat("moveSpeed", 0.0f);
}
else if (Input.GetKeyDown(KeyCode.Alpha5))
{
animator.SetFloat("moveSpeed", 5.0f);
}
}
}
1. 이동하고 싶다.
- Rigidbody / Capsule collider / 이동 스크립트
- trnasform 이동은 물리 충돌을 무시하는 경우가 발생함 -> 그래서 (사진2) 체크
2. 애니메이션 추가
Animator Controller
3. 카메라
728x90