Download

Possess without changing camera?

So the hardest challenge so far in learning unreal is how to work with a camera that is not attached to the player.

I want my game to eventually be multiplayer so I’m working on building in spawning/respawning blueprints, but I want all players to have a stationary camera not attached to the pawn they are controlling.

So far I’ve been able to do the initual spawn and camera control in the level blueprint like so:

However any attempts to do the same in another blueprint have come up short. I can set the player to possess another copy of thirdPersonCharacter by monitoring the destroyed event however I’m unable to get a reference to the camera in the scene anywhere but the level blueprint. Also I’d rather not have to reset the camera every time so they can control another pawn. Can’t I just set their controls to the pawn without switching camera views? (The character blueprint does not even have a camera attached to it).

Use GetAllActorsOfClass node to get reference to your camera by looping through the returned list in any blueprint

Sorry, but that’s not a solution. “GetAllActorsOfClass” node should be avoided as often as you can. This node is just for being lazy. If you have multiple Actors
that you need to track, they should register at your own made Manager Class on BeginPlay.

The correct solution would be prevent the Possess Node from setting the new Pawn as a view target. Sadly i have no idea if this is possible.
If have the same problem in my Game where i have 1 Camera that is linked to the Map. If i spawn the players and posses them, they all get their Pawns Camera
or at least the Pawn as a viewtarget.

What i did was just directly (in the same call, after the possess) set the camera back to the one i wanted to use.

If you need this camera in other Blueprints you have 2 options:

  1. Instead of placing the Camera, you spawn it. Do this in a class that you can easily access. For example in the GameMode or GameState. Since Spawning happens on the Server,
    you could use the GameMode (it is only spawned on the Server and not replicated!). Then you can get the spawned and saved reference to your camera every time you need.

  2. (Not really recommended) You can use the “BeginPlay” of the LevelBlueprint to pass the Camera down to other Blueprints.
    Make sure you only call this on the Server “SwitchHasAuthority”. Create a Variable in your Controller that can hold a reference to it and then just get the Controller, cast it and set the
    reference through the LevelBlueprint.

Thanks, that’s a good idea to spawn it so I have a reference. Strange this seems so complicated. It’s been pretty easy setting up everything for my game but having a stationary camera seems the most difficult by far.

If I’m correct, setting the camera back to what it was right after possessing should be fine, since both of these will happen in the same frame.

Yes, the problem he has is, that he is missing the reference to the old camera at this time x)

Right before he possesses, he should be able to do ‘Get Camera View’ for his player controller, and set that in a variable, and then use that as his reference.

(: Good answer. Didn’t know about that. But at least we gathered some general ideas for getting references.

Although this is the blueprint board, I have to say this is something that is more easy in C++ than in Blueprint as you are effectively overriding the default behavior built for you. An added advantage is it also allows you to implement more “strange” things later on.

That said, if I am to work on this I would store the reference to the camera that you wish to use in your PlayerState, then on every Possess call you revert back to use this camera stored as your view target.

One more possibility, especially when possessing various actors, would be to use the PlayerCameraManager instead; with this, you would need to implement the following and springarm logic yourself, but the camera is defined/added in the PlayerController instead of the character.

Cheers,
Indy