void ACinemotusPlayerController::OnSwichPawn(bool increase)
{
	//Get Current Pawn's rotation?

	if (PawnsInScene.Num() < 1)
	{
		return;
	}
	FString numstr = FString::Printf(TEXT("%d"), PawnsInScene.Num());
	GEngine->AddOnScreenDebugMessage(-1, .5f, FColor::Yellow, numstr);
	int startIndex = currentPawnIndex;
	do
	{
		if (increase)
		{
			currentPawnIndex = currentPawnIndex + 1 < PawnsInScene.Num() ? currentPawnIndex + 1 : 0;
		}
		else
		{
			currentPawnIndex = currentPawnIndex - 1 < 0 ? PawnsInScene.Num() - 1 : currentPawnIndex - 1;
		}
	} while (PawnsInScene[currentPawnIndex]->bHidden && currentPawnIndex != startIndex); //keep going till we find a non hidden one
	APawn* nextPawn = PawnsInScene[currentPawnIndex];
	
	Possess(nextPawn);
	SetViewTargetWithBlend(nextPawn, 0.0f);
	possessedCinePawn = Cast<ACinemotusDefaultPawn>(nextPawn);
	//GET JOYSTICK DATA
	GetCineData(GetPawn());

}
Ejemplo n.º 2
0
void AViewManager::BlendToTopDownView()
{
	auto Controller = this->GetWorld()->GetFirstPlayerController();
	/*auto PostProcessVolumeCenter = PostProcessVolume->Bounds.GetBox().GetCenter();
	auto PostProcessVolumeBoundsMax = PostProcessVolume->Bounds.GetBox().Max; */
	auto TopViewAnchorRotation = RootComponent->GetComponentRotation();
	FVector TopViewAnchorLocation = RootComponent->GetComponentLocation();
	TopViewAnchorLocation.Z += 2450; //@TODO Make this a function of something. Maybe some point where the camera frustum matches the bounding volume...

	TransitionTimer = 3.0f;

	TopViewAnchorRotation.Add(-90.0f, 0.0f, 0.0f);

	UE_LOG(LogTemp, Warning, TEXT("Top view location %f %f %f"), TopViewAnchorLocation.X, TopViewAnchorLocation.Y, TopViewAnchorLocation.Z);
	UE_LOG(LogTemp, Warning, TEXT("Top view rotation %f %f %f"), TopViewAnchorRotation.Pitch, TopViewAnchorRotation.Yaw, TopViewAnchorRotation.Roll);

	bool TransformSuccess = TopViewAnchor->SetActorLocation(TopViewAnchorLocation);
	TransformSuccess = TopViewAnchor->SetActorRotation(TopViewAnchorRotation);
	if (!TransformSuccess)
	{
		UE_LOG(LogTemp, Warning, TEXT("Not actor set somehow"));
	}
	
	Controller->SetViewTargetWithBlend(TopViewAnchor, TransitionTimer);

	{
		auto TopViewAnchorLocation2 = TopViewAnchor->GetActorLocation();
		auto TopViewAnchorRotation2 = TopViewAnchor->GetActorRotation();
		UE_LOG(LogTemp, Warning, TEXT("Top view location after transform %f %f %f"), TopViewAnchorLocation2.X, TopViewAnchorLocation2.Y, TopViewAnchorLocation2.Z);
		UE_LOG(LogTemp, Warning, TEXT("Top view rotation after transform %f %f %f"), TopViewAnchorRotation2.Pitch, TopViewAnchorRotation2.Yaw, TopViewAnchorRotation2.Roll);
	}

	IsInTransitionToPlanView = true;
	IsTransitionTimerCountingDown = true;
}
void ACinemotusPlayerController::SwitchToPawn(APawn* p)
{

	int pawnIndex = GetPawnListIndex(p);
	if (pawnIndex == -1)//not in list
	{
		//add
		PawnsInScene.Add(p);

	}

	SortPawnInSceneList();//incase layer change
	Possess(p);
	SetViewTargetWithBlend(p, 0.0f);
	possessedCinePawn = Cast<ACinemotusDefaultPawn>(p);
	//GET JOYSTICK DATA
	GetCineData(GetPawn());
}