2025-01-31TIL 나선운동 엑터,interface,LevelDesign

별빛에소원을·2025년 1월 31일

TeamSparta-Unreal1기-TIL

목록 보기
34/90
post-thumbnail

알고리즘

꾸준히 하다보니까 이전에 하던 것들과 겹치는 것들도 생겨서 고통은 받았지만 전보단 덜했다.

나선운동

  • 회전은 sin Y radius, cos X radius 를 통해 좌표를 만들되, angle값은 미리 지정해준다.
  • z값은 미리 설정한 스피드 대로 상승시킨다
  • 상승폭보다 작은 경우 새로 생성을 해야한다.
  • 일정 높이까지 도달한 경우 삭제한다.
void ASpiralActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	// raidus * cos x, sin y
	if (!ListRotationFootrest.empty())
	{
		FVector Local = GetActorLocation();
		auto iter = ListRotationFootrest.begin();
		auto iter_end = ListRotationFootrest.end();
		size_t Size = ListRotationFootrest.size();
		FloorCount = 0;
		for (uint32 i=0;iter != iter_end;++i) 
		{
			if (iter->IsValid())
			{
				ARotationFootrest* SpawnedActor = iter->Get();
				SpawnedActor->AddAngle(SpiralSpeed * DeltaTime);
				float AngleDegrees = SpawnedActor->GetAngle();
				float AngleRadians = FMath::DegreesToRadians(AngleDegrees);
				
				float RotX = Local.X + FMath::Cos(AngleRadians) * Radius;
				float RotY = Local.Y + FMath::Sin(AngleRadians) * Radius;
				float RotZ = SpawnedActor->GetActorLocation().Z + (RisingSpeed * DeltaTime);
				FVector Location = {RotX, RotY, RotZ};
				SpawnedActor->SetActorLocation(Location);
				
				if (SpawnedActor->GetActorLocation().Z - Local.Z <= Floor)
				{
					++FloorCount;
				}

				if (RotZ - Local.Z >= HeightMax)
				{
					SpawnedActor->Destroy();
				}
				++iter;
			}
			else
			{
				iter = ListRotationFootrest.erase(iter);
			}
		}
		//UE_LOG(LogTemp, Display, TEXT("Floor Count: %d"), FloorCount);
		if (ListRotationFootrest.back()->GetActorLocation().Z - Local.Z > HeightIncrease && FloorCount < 1)
		{
			auto Footrest = CreateRotationFootrest();
			Footrest->AddAngle(ListRotationFootrest.back()->GetAngle() + DefaultAngle);
			FVector NewLocal = FVector::ZeroVector;
			NewLocal.Z = Local.Z;
			Footrest->SetActorLocation(NewLocal);
			ListRotationFootrest.emplace_back(Footrest);
		}
	}
}

InterFace

언리얼에서는 interface를 제공한다
interface는 특정 기능을 확장하기 위한 컴포넌트와는 다른 개념이고 다중상속을 이용해
특정기능만을 추가하고싶은 경우 사용하게 된다.

TriggerVloume

특정 레벨에서 동작해야하는 이벤트가 있을 경우 사용한다.
instance에서 관리하면 좋다고 한다.

레벨디자인

미로만들기

미로 생성 강의를 봤다 만들까 싶었는데 그럼 레벨 문제가 생겨서 일단 기록만 해둔다.

profile
취미로 게임하는사람

0개의 댓글