bool UWaypointComponent::HasChildBoxCollision()
{
	TArray<USceneComponent*> children;
	GetChildrenComponents(true, children);
	for (auto component : children)
	{
		auto boxCollision = Cast<UBoxComponent>(component);
		if (boxCollision == nullptr)
		{
			continue;
		}
		if (boxCollision->ComponentHasTag(FName("Waypoint")))
		{
			return true;
		}
	}
	return false;
}
예제 #2
0
TArray<ASprungWheel*> UTankTrack::GetWheels() const
{
	TArray<ASprungWheel*> ResultArray;
	TArray<USceneComponent*> Children;
	GetChildrenComponents(true, Children);
	for (USceneComponent* Child : Children)
	{
		auto SpawnPointChild = Cast<USpawnPoint>(Child);
		if (!SpawnPointChild) continue;

		AActor* SpawnedChild = SpawnPointChild->GetSpawnedActor();
		auto SprungWheel = Cast<ASprungWheel>(SpawnedChild);
		if (!SprungWheel) continue;

		ResultArray.Add(SprungWheel);
	}
	return ResultArray;
}
UBoxComponent* UWaypointComponent::GetChildBoxCollision()
{
	TArray<USceneComponent*> children;
	GetChildrenComponents(true, children);
	for (auto component : children)
	{
		auto boxCollision = Cast<UBoxComponent>(component);
		if (boxCollision == nullptr)
		{
			continue;
		}
		if (boxCollision->ComponentHasTag(FName("Waypoint")))
		{
			return boxCollision;
		}
	}
	UE_LOG(LogTemp, Warning, TEXT("Component Cast Failed."));
	return nullptr;
}