251229 TIL - 5번 과제 제출일 + 팀프로젝트 발제

2025. 12. 29. 21:04언리얼 7기 본캠프

오늘은 코드카타 이후 언리얼C++ 첫 과제를 제출했는데... 과제 내용을 제대로 읽지 않고 과제를 만드는 바람에 완전히 혼날 예정 ㅠㅠ

함수를 만들어서 액터를 움직여야하는데 함수를 만들라는 내용을 인지하지 못해서 그냥 쌩으로 코드를 박아버림

해설을 들으면서 깨달은 부분이라 이제와서 수정할수도 없고... 눈물...

 

void AA_Actor::BeginPlay()
{
	Super::BeginPlay();
	
	FVector ActorLocation = GetActorLocation();
	FRotator ActorRotation = GetActorRotation();
	FVector ActorScale = GetActorScale();
	FVector FormerActorLocation = GetActorLocation();
	FVector DirectionVector;

	double LocMin = -200;
	double LocMax = 200;
	double RotMin = -180;
	double RotMax = 180;
	double ScaMin = 0.3;
	double ScaMax = 2.5;

	int Cnt = 0;
	double TotalDistance = 0;

	if (GEngine) {
		for (int i = 0; i < 10; i++) {
			SetActorLocation(FVector(FMath::RandRange(LocMin, LocMax), FMath::RandRange(LocMin, LocMax), FMath::RandRange(LocMin, LocMax)));
			ActorLocation = GetActorLocation();
			GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("Current Location : %s"), *ActorLocation.ToString()));
			DirectionVector = FormerActorLocation - ActorLocation;
			TotalDistance += DirectionVector.Size();
			FormerActorLocation = ActorLocation;
			SetActorRotation(FRotator(FMath::RandRange(RotMin, RotMax), FMath::RandRange(RotMin, RotMax), FMath::RandRange(RotMin, RotMax)));
			ActorRotation = GetActorRotation();
			GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("Current Rotation : %s"), *ActorRotation.ToString()));
			if (RandomEvent(50)) { // 이벤트 발동시 랜덤 스케일 조정 이벤트 발생
				SetActorScale3D(FVector(FMath::RandRange(ScaMin, ScaMax), FMath::RandRange(ScaMin, ScaMax), FMath::RandRange(ScaMin, ScaMax)));
				ActorScale = GetActorScale();
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("Current Scale : %s"), *ActorScale.ToString()));
				Cnt++;
			}
		}
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("Total moved distance : %f"), TotalDistance));
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, FString::Printf(TEXT("Total random event activated : %d"), Cnt));
	}

}

쌩코딩의 흔적...

 

이후 반복코딩 세션 포인터편을 들은 후 대망의 팀프로젝트 발제를 들었음

과제 자체는 충분히 할만한 내용이었지만 팀원분들과 같이 깃허브에서 작업해야하는게 좀 어렵지 않을까 걱정됨. 깃허브는 아직도 사용법이 적응이 안되기도 하고...

그래도 화이팅해서 팀프로젝트 마감할 수 있었으면 좋겠음