UE4 Character movement fine tuning

주홍영·2022년 3월 25일
0

UE4

목록 보기
4/5

앞선 방법으로 구현을 했을 때
character가 향하는 방향이 카메라 시점과 일치하는 모습을 보여 줬다
따라서 이를 방지하기 위해 다음의 코드를 constructor에 정의한다

	// Don't rotate when the controller rotates
	// Let that just affect camera.
	bUseControllerRotationYaw = false;
	bUseControllerRotationPitch = false;
	bUseControllerRotationRoll = false;

위 코드를 이용하여 controller가 회전할 때 캐릭터가 같이 회전하는 것을 방지한다

그리고 캐릭터가 움직이는 방향으로 mesh가 바라보게 해주기 위해서 다음의 코드를 작성한다

	// Configure character movement
	GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 360.f, 0.0f);  // ...at this rotation rate
	GetCharacterMovement()->JumpZVelocity = 450.f;
	GetCharacterMovement()->AirControl = 0.2f;

bOrientRotationToMovement를 true로 설정하여 character가 움직이는 방향으로 움직이도록 설정
RotationRate로 rotation rate를 설정
JumpVelocity는 jump시 시작속도이고
AirControl은 공중에서 move를 시도했을 때 가능한 정도 이다
만약 1.0f 라면 지상에서와 똑같이 움직임을 가져갈 수 있다

profile
청룡동거주민

0개의 댓글