Possessing character without creating a Camera

Hello, im a beginner with unreal and im having an issue that many people also have, but none of the solutions i found online worked for me…

Here is the situation, i have 2 character in the level, one is a mecha the second one is the player.
i need to be able to possess my mecha with my player and then as the mecha i need to be able to repossess my player back.

i managed to do it, in the level blueprint when a key is pressed it flip-flop between the 2 possession.

The issue :
When i possess another character, no matter what, it create a camera inside the head of the mecha, even if the mecha character have zero camera attached to it, possessing it still create a camera inside its head.

But i absolutely dont want that, i want to be able to possess my mecha while keeping the previously active camera.

Solutions i tried :
1:
Some people are saying that there is an option to “disable auto camera management” in the controller, but i searched and i dont have any controller in my content drawer… where is that parameter found ?

2:
an other solution i’ve seen is to use an “Event Possessed” in the mech Blueprint and link that to a set view with blend and as a target find the previously active camera.
That would do the following : possess my mecha, create this unwanted camera but instantly switch it back to the previously active camera.

However this solution dosent work for me, because the set view target have multiple issues :
2-1
its a “target is player controller” so i’m plugging the “get player controller” in the target but it create an error when i close the game saying : “accessing none while trying to get player controller”

2-2
i cannot plug my camera anyway because my previous camera is a “cinecamera component” and the new view target requires a camera actor

The last solution i found is about enabling input on one character while disabling the input on the previous character and reverting that operation when i want to switch again, but the issue here is that i have ZERO clue on how to do it, i guess i need to create another controller but i dont understand what is a “controller” and i dont know how to configure it anyway.

Sorry for the long post, i tried everything in my capacity and searched for solutions for hours, but im stuck.

Image : my current system in the level BP to flipflop between my characters


Image 2 : the BP of my mecha, where im trying to revert the camera after event possessed

Image 3 : The camera that is created inside my mecha’s head

Have you checked out the following?

HTF do I? Change Cameras in Unreal Engine 4 Blueprints (youtube.com)

The way I would go about this setup is by having each possessable pawn have a camera (potentially with a spring arm) like the base 3rd person character template. Then when I possess another pawn I would move that pawns camera “close” to where the previous pawns camera was ( at least in distance and look angle) and then blend between the two. Make sense?

I feel like your approach might be going against the grain of the expected possession mechanics which is why others might be having issues as well. Whenever you do that you will need to delve deeper into custom mechanics which can get complicated fast.

EDIT:

I don’t believe this will be necessary as the default should do just fine for this part of the setup

A controller is what a player or AI (NPC) use to control a Pawn. In the case of a player, it is called the Player Controller.

If you don’t want the mecha to create a camera (I didn’t even know this was a thing), I wouldn’t try to possess it, I would simply enable input for the mecha. You can do this with any Actor, not just Pawns. The Actor (or Pawn in your case) will ALSO receive input events.

If you are using the enhanced input system, I wouldn’t disable input in the first character. Instead, I would have one set of input events for one character and another for the other, and switch the context. Then you could in theory (depending on what you are doing exactly) just let the mecha always receive input and decide which context to use at any moment. Also, you could allow both to respond to common input events, if you have a need for that as well.

image

image

1 Like

This sounds like a smart solution, this possession system dosent seem to be good for my situation.

I have 3 systems

  • The player BP
  • The mecha BP
  • The seat BP (It is where the player will interact to control the mecha)

Currently, i’m doing the possession inside the seat BP but i just cant figure it out.

How would you proceed with your solution ?
Have all the inputs in the Player BP and retrieving a bool saying (im sitting in the Seat BP) so now control the mecha ?

i have no clue on how to do that, could you show me an example of controlling 2 character pawns via one character only ?
(you can also point me to a tutorial if it’s too complicated)

By Engine default a possessed Pawn without a camera will be given one by the Camera Manager.

1 Like

Let’s backup a bit…

The camera you want to use is attached to the Player BP, yes? If so, I would try the following:

  1. possess the Player BP
  2. define input actions for the Player BP (to drive the camera)
  3. setup the input events in the Player BP
  4. define input actions for the mecha BP (to drive the mecha)
  5. setup the input events in the mecha BP
  6. set the mecha BP to enable inputs*
  7. (unnecessary step removed)

*I believe these need to be done on the owning client machine, not the server. But initially just try to get this to work on a single listening server to get it working.

You can keep the seat BP, but it won’t play any role in any of the input processing.

Try this much first with one set of input keys for the camera and another set for the mecha and see if they both receive their respective input events.

EDIT: This works for me when mecha is an Actor, but it doesn’t work when it is a Pawn, I am trying to figure out why.

EDIT 2: I remember now that in one of my prototypes (in my effort to look for the best solution), I was able to drive my tank without possessing it, but because it was a Pawn, I had to attach an Actor to it as a child (ActorComponent). This made it possible to pass the input to the Seat Actor via input events. I would enable inputs on that Actor Seat and it would drive the Pawn by virtue the Pawn was its parent Actor, so it knew how to find the appropriate events to send the input parameters down to, essentially an API of sorts.

All Possession needs to happen on the Server. Preferably in the Game Mode where all initial pawn → controller possession /un-possession occurs.

  1. Un-Possess Character
  2. Remove Input context mapping from character
  3. Possess Mech
  4. Add input context mapping to Mech.
  5. Adjust camera location/rotation on mech to match character.

Movement applies to Pawn class.

Im going to explain a bit more about the camera ;
The player have the default camera boom, so the camera follows you as you walk around.
When the player sit in the control Desk, the camera change to an external camera, this camera is an actor placed in the level
(i made it that way so it is not an annoying component that i cannot use in “set view target with blend”)

Im also providing a little drawing so you can understand what i’m trying to achieve

I need clarifications ;

  • possess the Player BP

The player is active by default, i placed both the player and the mech in the level (so they are character actors i guess ?)

Since im playing the Player BP by default do i need this initial possess step ?

  • define input actions for the Player BP (to drive the camera)

This step, im not sure what you mean, my player Bp is already able to walk around, jump and so on…

  • setup the input events in the Player BP

Again, im not sure what you mean…

  • define input actions for the mecha BP (to drive the mecha)

Same as the player, the mecha BP is already able to walk around when i control it (IA_Move and so on)

  • setup the input events in the mecha BP

Same, not sure what you mean…

  • set the mecha BP to enable inputs*

How would i do that, i guess i should use the node Enable inputs but from where ?
from the player BP ? from the mecha BP itself ?

Im really sorry if i sound dumb, but this is very hard for me to understand, could you provide a visual example on how you control a character actor FROM your player BP ?

I guess i need to have a different set of input actions (like IA_Move, IA_Shoot) in my player BP and send theses informations to my Mecha Character BP somehow so the input “walk” from the player use the walk speed of the mecha and actually makes the mecha move, but i have no clue on how to do it…

I understand better now what you are trying to do.

If you can possess the mecha and then back again to the player, then I would do the following:

  1. Add a camera to the mecha.
  2. In the mecha Tick event, set the camera to a location where you want it in world location and rotation.

I assume you can add a Cinecamera to the mecha, haven’t tried it, but it would prevent the mecha spawning a basic camera. The Tick event should place the camera in the same location just before each frame is rendered. The world location will be absolute to the level, not relative to the mecha.

Okay guys i finally figured a solution for my possession problem.
it took a lot of trial and error and the solution will greatly depend on your own specific case.

The thing i did first is to manage all the possession in one BP, the BP that is in between my 2 characters.

There is 3 BP in my case

The Player
Its the player main character, based on the default BP_Thirdpersoncharacter

He can interact with the control desk to take control of the Mecha.

The Mecha :
Its a robot that is controlled from the control desk by the player, he has unique abilities that the player dont have, it have its own settings (walk speed and so on)

The Control Desk :

Its a control desk with a seat for the Player and some PC screen that display the view of the Mecha, when the player interact with it, he sit on the chair and immediately control the Mecha while keeping the camera with an angle on the control Desk.

Here what i did to solve my issue :

  • i made all the possession system inside the “Control BP”
  • Created an Blueprint Interface linking to the 3 objects. (Mecha, Player, Control Desk) it have 2 function ; Interact with Desk and Exit Vehicle.
  • Used inputs keys in the “Player BP” to Call a Interact Message to interact with the Desk
  • Created an input key in the “Mecha BP” To an “Exit vehicle” Message when it is possessed
  • In the “Control BP”
  • In “Control BP” instead of using the “cast to player” and “cast to mecha” i instead used references to the characters placed in the level (the pawns)
  • For the cameras to use after the possession instead of using a camera component (camera inside the BP) i used a camera actor played in the level and took a reference to it in my Control BP
  • When possessing the Mecha, i needed to switch the camera, right after the possession, using a set view target with blend and pointing to my level actor camera in the “new view target” input and a “get player controller” in the target input
  • When im controlling the mecha after possessing it, i needed a way to revert back to the player ; instead of doing an “unpossess” i did another possess again pointing to the player (the reference of the player pawn placed in the level)
  • When possessing the player back (reverting from the mecha gameplay back to the player gameplay) i had the issue where my Mecha would freeze completely, loosing its momentum. So if the Mecha was falling in a pit for example, when possessing the player back the mecha would freeze completely. To solve this i had add a “spawn default controller” right after the possess node.

Advanced issues :

When exiting the Mecha to control the player again, the mecha would continue to fall (due to gravity) (this was solved on the point above) but the Mecha also have a “Dash Ability” which is a “launch character” node inside the “Mecha BP” this “Dash” velocity was not conserved when exiting the mecha, leading to an issue where if (as the Mecha) you Dash forward and immediately exit the Mecha back to the player, the Mecha would freeze. To solve this issue i had to (in order) : Store the velocity of the Mecha with a “Set Mecha velocity” → Possess Player → Spawn default controller on the mecha → Set simulate physics ON (mecha) → add impulse with the “Get Mecha Velocity” → Set Simulate Physics OFF (mecha)

However, for this to work, you cant use the reference to the Mecha Pawn in the level, you need a valid cast AFTER the possession.

The same logic applies when the player Enter the mecha because if the Mecha is launched and slide for a long time, you have the time to exit and immediatly re-enter the Mecha, therefore you need to pass its velocity again when re-entering.
(this step might be confusing to explain, i would recommend to not bother exept if you get this problem)


(uncompressed image link : Fix-Possess hosted at ImgBB — ImgBB )

Here is a screenshot of my Control Blueprint system, im sorry for the quality, but my code is so long i had to assemble multiple screenshots together to show the whole thing.
Note : in my code :
Scaf = Mecha Actor Reference from the level
Cast to BP_Scaphandre = The Mecha BP

I know all of this sounds very complicated, i think the complexity really comes from the concept of my game that have some very specific conditions and therefore making the coding of this very complicated.

If your concept is simpler, you should be able to solve the issue with only a fraction of my code.

Hopefully this might help someone one day.
Thanks to all of you guys for the help !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.