Download

[C++]: Switch camera based on controller type.

Hi guys… me again…

So my game is going to have two portions, an offline and an online portion. Each portion will have a different camera setup. Each portion also has it’s own gamemode and controller, but would share the same player pawn.

I was wondering if it’s possible to switch cameras based on which controller is currently being used, code below:



void ASmashyCharacter::PossessedBy(class AController* InController)
{
	Super::PossessedBy(InController);

	ASmashyPlayerController* OnlineController = Cast<ASmashyPlayerController>(GetController());
	ASmashyOfflineController* OfflineController = Cast<ASmashyOfflineController>(GetController());
	if (Controller != NULL)
	{
		FViewTargetTransitionParams params;
		if (Controller == OnlineController)
		{
			OfflineCamera->Activate(false);
			FollowCamera->Activate(true);
		}
		if (Controller == OfflineController)
		{
			FollowCamera->Activate(false);
			OfflineCamera->Activate(true);
		}
	}

	// [server] as soon as PlayerState is assigned, set team colors of this pawn for local player
	UpdateTeamColorsAllMIDs();
}


Breakpoints show that the correct controllers are being called, and that it’s comparing the controllers properly, and even shows that it’s reaching the Activate() for each camera depending on which controller is in use. But the camera never switches, i’ve tried this using a button input and the same comparison code and got nothing. Any ideas?

Each Controller can have an own CameraManager class that you can set on the Controller constructors:

PlayerCameraManagerClass = OfflineCamMan:: StaticClass

to another…

PlayerCameraManagerClass = OnLineCamMan::StaticClass

After override the “UpdateViewTarget” method on each class setting your cameras angles, distances, FOV…

I think this will give you the desired behaviour.

That seems like overkill for what i’m trying to do… the actor has two cameras attached to it, all i want to do is disable one and enable the other.

The only thing I’ve seen that could perform camera “cuts” is Matinee (at Controller level), other than this I’m switching cameras the way I tould you.
If someone has a better/easy way to do this, I’ll also be interested in know. :smiley: