TIL day 30

2025. 1. 31. 21:01·TIL

1. 코딩테스트


오늘 오전 코딩테스트는 프로그래머스의 level 2 큰 수 만들기를 풀었습니다.

https://school.programmers.co.kr/learn/courses/30/lessons/42883

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

  • 뭘로 풀지?
    • 스택이랑 그리디

2. 언리얼 과제 진행


필수 과제 현재 진행 상황 (Pawn으로 캐릭터 구현하기)

  • Pawn을 상속받아서 캐릭터 만들기
    • Pawn 클래스 생성
      • CapsuleComponent, SkeletaMeshComponent, SpringArm, CameraComponent 를 추가하였고,
      • Root Component 로 CapsuleComponent를 지정하였습니다.
    • GameMode 설정
      • GameMode를 bp로 만들어, 
      • 디폴트 폰을 C++로 만든 PlayerCharacter 클래스로,
      • 플레이어 컨트롤러를 C++로 만든 PlayerCharacterController 클래스로 설정하였습니다.
    • Player Controller 생성
      • Enhanced Input 으로 Move Action, Look Action 생성하였습니다.
      • 이때, 모든 세팅을 ConstructorHelpers를 통해 C++로 하였습니다.
//PlayerCharacterController.cpp 생성자
//Input Mapping Context와 Input Action을 C++로 세팅

APlayerCharacterController::APlayerCharacterController()
	:InputMappingContext(nullptr)
	,MoveAction(nullptr)
	,LookAction(nullptr)
{
	static ConstructorHelpers::FObjectFinder<UInputMappingContext>IMC_PlayerCharacter(TEXT("/Game/Inputs/IMC_PlayerCharacter.IMC_PlayerCharacter"));
	if (IMC_PlayerCharacter.Succeeded())
	{
		InputMappingContext = IMC_PlayerCharacter.Object;
	}

	static ConstructorHelpers::FObjectFinder<UInputAction>IA_Move(TEXT("/Game/Inputs/IA_Move.IA_Move"));
	if (IA_Move.Succeeded())
	{
		MoveAction = IA_Move.Object;
	}

	static ConstructorHelpers::FObjectFinder<UInputAction>IA_Look(TEXT("/Game/Inputs/IA_Look.IA_Look"));
	if (IA_Look.Succeeded())
	{
		LookAction = IA_Look.Object;
	}
}
  • Pawn 이동 로직
    • AddActorLocalOffset과 AddActorLocalRotation으로 이동과 회전 구현
    • 주의할 점) 마우스로 Pitch 회전을 하는 경우 캐릭터가 아니라 Spring Arm을 회전시키도록 구현하여 원래 캐릭터로 AddControllerPitchInput 함수를 사용한 것과 같은 효과 구현
//PlayerCharacter.cpp의 Look 함수

void APlayerCharacter::Look(const FInputActionValue& value)
{
	const FVector2D LookInput = value.Get<FVector2D>();
	FRotator NewRotation = FRotator(0.f, LookInput.X, 0.f) * LookSpeed * GetWorld()->GetDeltaSeconds();
	
	AddActorLocalRotation(NewRotation);

	SpringArmComp->AddLocalRotation(FRotator(LookInput.Y, 0.f, 0.f));
}

동영상 서비스가 종료되어 해당 콘텐츠를 재생할 수 없습니다.

 

 

도전 과제 진행 상황 (Pawn으로 드론 구현하기)

  • Pawn 클래스의 특징을 이용하여, 드론의 움직임을 구현하였습니다.
  • 위에서 만든 Character에 기능을 추가하여 구현하였습니다. 
    • Input Action 추가
      • Roll Action & UpDown Action
        • Enhanced Input에서 Scalar 값을 사용했습니다. (내용 추가 정리 예정)
        • AddActorLocalRotation 과 AddActorWorldOffset 사용
    • 중력 추가
      • Tick 함수에서 중력 적용
      • 지면과 충돌 처리 (물리 사용x)
  • 아직 구현을 못 한 부분이 많습니다. 구현하면서 추가로 공부한 내용도 추가할 예정입니다.
  • 현재까지의 모습

동영상 서비스가 종료되어 해당 콘텐츠를 재생할 수 없습니다.

 

'TIL' 카테고리의 다른 글

TIL day 32  (0) 2025.02.04
TIL day 31  (0) 2025.02.03
TIL day 29  (2) 2025.01.27
TIL day 28  (2) 2025.01.24
TIL day 27  (0) 2025.01.23
'TIL' 카테고리의 다른 글
  • TIL day 32
  • TIL day 31
  • TIL day 29
  • TIL day 28
gbleem
gbleem
gbleem 님의 블로그 입니다.
  • gbleem
    gbleem 님의 블로그
    gbleem
  • 전체
    오늘
    어제
    • 분류 전체보기 (189)
      • Unreal Engine (73)
      • C++ (19)
      • 알고리즘(코딩테스트) (32)
      • TIL (60)
      • CS (4)
      • 툴 (1)
  • 블로그 메뉴

    • 홈
    • 카테고리
  • 링크

    • 깃허브
    • velog
  • 공지사항

  • 인기 글

  • 태그

    DP
    C++
    gamestate
    상속
    applydamage
    blend pose
    매크로 지정자
    enhanced input system
    Vector
    const
    motion matching
    map을 vector로 복사
    BFS
    싱글턴
    addonscreendebugmessage
    템플릿
    actor 클래스
    cin함수
    character animation
    additive animation
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
gbleem
TIL day 30
상단으로

티스토리툴바