I have a custom camera class, which exposes the transform of a hidden sphere sitting slightly in front of it at all times. I wish to access this variable from other blueprint classes, but that would first require a reference to my custom camera class. The issue here is that my game mode intentionally doesn’t use a default pawn, and casting a player’s Player Camera Manager to my custom camera class always seems to give me compiler warnings, stating that the cast will always fail.
So how can I set things up to where I can have a custom camera class, assigned to each player in the game, and be able to access that camera in (preferably) all other blueprint classes? Would I require any other subclasses, such as a Player Controler?
You can’t cast a camera to a camera manage because they are fundamentally not the same thing. You should brush up on your object oriented programming a bit.
Why not create a default pawn class for the players, add a camera to it. Then add a scene component and attach it to the camera, with a relative offset of like 20,0,0. You can use the scene component to get your world transform.
This is kinda exactly the sort of thing you might use a default pawn for. A pawn doesn’t have to be a character in the game, it’s just something that you “possess” and take control of as the player. Lots of games use pawns that are just spectator or “ghost” cameras, such as the one I describe.
If for some reason you can’t use a pawn (because you posses something else,) you could just set up an actor that does the same thing and spawn it and save the reference somewhere.
Considering how players should have zero control over camera movement, and each player will simply be a camera and nothing more (no mesh, etc), the default pawn for my game mode is set to “None”. It’s a simple card game, and the cards aren’t pawns. There is a deck of cards (instanced static meshes), and each individual card in the deck will eventually end up in several places within the scene… But halfway from the deck to laying elsewhere in the scene, the cards need to go into a “CardHand” which is owned by a player, so making a pawn class for this would be rather frustrating.
So there is no pawn, and nothing AFAIK is being possessed.