Animation

Ryan Ham·2024년 6월 19일
1

Unreal Engine

목록 보기
11/27

https://www.unrealengine.com/ko/blog/unreal-property-system-reflection

  1. 정지해 있을때 공격 모션
  2. 이동중이면서 공격하는 모션

skeleton을 나누어서 각각 다른 animation을 구현
하체 부분은 달리는 모션 + 상체 부분은 공격하는 모션

layered animation

C++ 파생 클래스 생성 -> 그 클래스를 상속받는 클래스 생성

FRotater(pitch, roll, yaw) <- 이 순서대로인가?

Collision
Collision profile , Channel 설정

PlayerCharacter 생성자에서
GetMesh() -> SetCollisionEnabled()
GetCapsuleComponent()->SetCollisionProfileName()

GameMode

실재 사용할 level이랑, 실재 사용할 GameMode 만들기
새로운 level에서 사용할 gamemode 만들기
C++ 클래스 추가 > GameModeBase

프로젝트 맴&모드에서 기본으로 지정한 gamemode를 하면 world setting에서고 default로 이걸 사용
하지만 world에서 따로 지정을 하면 그게 gamemode가 된다. (world에서 지정한 gamemode가 더 우선순위가 높다)

gamemode에서 defaultpawnclass를 바꾸기
beginplay에서 defaultpawnclass를 지정해봤자 아무 소용이 없다.

defaultpawncalss는 시작지점에서 자동으로 pawn을 spawn하고 자동 빙의

FRotater() - Pitch, Yaw, Roll


Game mode - defaultpawnclass

In Unreal Engine, the DefaultPawnClass in a GameMode class determines the type of pawn that the player will automatically spawn with when they join the game. The pawn is essentially the player's avatar in the game world, responsible for handling the player's movement and interactions.

Here's a detailed explanation of how DefaultPawnClass works:

Purpose of DefaultPawnClass
Default Player Character: It specifies which class to use for the player's character or pawn when the game starts. This is the character that the player will control by default.
Automatic Spawning: When a player joins the game, the GameMode uses the DefaultPawnClass to spawn an instance of the specified pawn class at the player start location.
Customization: Developers can set this to any custom pawn class they have created, allowing for a variety of player avatars with different capabilities and behaviors.


Enhanced Input system

이동과 회전은 중복 setting이 되어야 한다.
둘 다 cumulative

IMC도 consturctorHelpers에 넣어준다.
Input Action에서 Asset scope 지정하는 꿀팁 check 하기

*PlayerCharacter.cpp
BeginPlay >
Player Controller에 IMC call하기

  • IA 가 binding하기

*Input
Input.h, Input.cpp에 tesp input IMC, default input IMC 둘다 구현한다.

*Enhanced Input
- Input.h, Input.cpp에서 만드는 부분
- Character 부분에서 binding하는 부분


Animation 부분

cube나 static mesh에는 animation을 적용할 수 없다.
반드시 skeletal mesh에만 적용 가능.

viewport에서 캐릭터 클릭 -> 애니메이션 -> 애니메이션 모드 -> 애니메이션 블루프린트
그냥 하나의 애니메이션만 보여주고 싶다면 use animation asset
우리가 원하는 대로 직접 animation을 조작하고 싶다면 use custom animtaion
우리가 쓸거는 animation blueprint 모드

Anim class

UAnimInstance라는 것을 상속받아서 Animation Blueprint를 만든다.
What is UAnimInstance ?

Animation에 시간 투자 많이 할 것.
Animation 디테일하게 할 것.

애니메이션 블루프린트 만들때 parent class를 꼭 우리가 만든 custom player animinstance로 만들 것

다른 skeletal mesh로 만들어진 ABP animation


Unreal Engine version 관리를 할때는 build target이랑 editor target을 그것에 맞는 버전으로 바꾸어 주어야 한다.
Unreal Engine migration

STEP 1. skeletal mesh + Input Action + Input Action Mapping 설정하기
STEP 2. Animation Blueprint 만들기
STEP 3. 애니메이션 -> 애니메이션 모드 + 애니메이션 클래스 설정하기
STEP 4.

Animation은 class이기 때문에 fobject finder가 아니라 fclass finder를 써서 가지고 와야 한다.

fclassfinder로 class path를 가지고 올때는 반드시 뒤에 _C를 붙여주기!

anim blueprint를 가지고 왔으면 가지고 있는 skeletal mesh component에 이거를 넣어주기


Layered animation

가만히 있을때 => Idle animation
달릴때 => Running animation

Blend Space로 먼저 만들어 보기

Blend space & Aim offset
Aim offset : 캐릭터가 aim을 돌렸을때 캐릭터의 skeletal mesh의 허리, 목등이 자연스럽게 움직이는 animation

Blend Space 2D는 가로축, 세로축 2개가 있다.
가로 : 방향
세로 : 이동속도

샘플 이름 표시하는 버튼 체크하기
BlendSpace만들고 이를 animation sequence와 동일하게

C++에서 Blueprint에서 visible하게 만드는 옵션을 UPROPERTY에서 만들 수 있다.
UPROPERTY(VIsibleAnywhere, BlueprintReadOnly)
UPROPERTY(VIsibleAnywhere, BlueprintReadWrite) < 읽고 수정까지 가능.

UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
float mMoveSpeed = 0.f;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
float mMoveDir = 0.f;

Animinstance
SkeletonMesh

nativeupdateanimation

nativethreadsafeupdateanimation

UnrealEngine의 Cast
APlayerCharacter* PlayerCharacter = Cast(TryGetPawnOwner());

character의 속도값을 얻어올떄는 character movement component 아니면 pawn의 pawnmovement에서 얻어올 수 있다.

UCharacterMovementComponent* Movement = PlayerCharacter->GetMovement
mMoveSpeed = Movement->Velocity.Length() (벡터를 스칼라로 만들어줌.)

부모 클래스의 member variable보고 싶으면 <내 블루프린트>가 아닌 클래스 디폴트에서 확인할 수 있다.

Direction 같은 경우는 3x3의 경우의 수가 나올수가 있다.
각 축 방향으로 +, 0, - 의 값.

Remind : BlendSpace에서는 moveDir이 한 축, speed가 한축이다.

각각의 경우에서 mMoveDir의 변수를 C++상에서 바꿔준다.
그러면 Blueprint에서는 아까 전에 설정한 UPROPERTY의 blueprintreadonly를 통해
BP_blendspace에서 해당하는 animation을 틀어준다.

TObjectPtr는 Object class에서 auto랑 비슷한 느낌


방법 2. Blend Space를 쓰지 않고 만드는 방법
** Unreal Animation State Machine

Animation blueprint => state => state(더블클릭) => state추가
각각의 state마다 하나의 animation sequence가 들어가 있다.
State랑 State를 연결하면 그 중간에 transition이라는 것이 생성된다.

Transition에는 True/False가 들어오면 된다.

PawnMovement에서는 GetCurrentAcceleration을 통해 가속도를 가져올 수 있다.
Paragon animation blueprint를 분석해보자.

https://dev.epicgames.com/documentation/en-us/unreal-engine/lyra-sample-game-in-unreal-engine?application_version=5.4

Lyra Starter Game
5.4 새로운 animation

Movement->IsFalling()도 지원해주고 있다.

여기서는 blend space에서보다는 더 세분화하게 animation을 나눈다.
가속도가 있을때는 runstart.
runstart가 끝나면 run으로 자연스럽게 연결.

profile
🏦KAIST EE | 🏦SNU AI(빅데이터 핀테크 전문가 과정) | 📙CryptoHipsters 저자

0개의 댓글