How do create a camera to unlocks from the player when I want to pan it with WASD controls

I started with the basic top down game project from UE5 and am completely new to all this. I looked up tutorials and forums about creating a panning camera in the game which I was successful at but when I move the character with left click, the camera would still move with the character.
So I am trying to find a way to unlock the camera from my character when I pan it, and relock it when I reselect my character (which I havent gotten yet) and it follows the playerr again. Very much like how Baldurs Gate 3 or Divinity Original Sin does it

What a coincidence :smile: Your objective is the combination of some of my recent approaches for other people! Hold on for a moment.

Alright! So is this your objective?

  • The map can be freely navigated with the camera
  • While not locked on, the player character’s location doesn’t affect the view
  • The camera smoothly locks on the player charater on input
  • When locked, only player character’s location determines the view

Here’s the setup, along with some extra stuff like zooming and clamping :wink:

Create a character class blueprint for the player character, but do not add any camera or spring arm components to it.

Then create a pawn class blueprint for the camera and add a camera component to it. You can also set it a tilt directly from the viewport.

Here’s the Event Graph of the player character’s blueprint:

Above :point_up: are the related parts to the control of the player character. Below are also inside the same Event Graph, but parts related to the control of the camera:

The timeline:

And the Event Graph of the camera pawn:

And finally, the collapsed graph for clamping:

Hope this helps! :innocent:

The above post seems pretty elaborate and possibly has just what you want. My understanding (as I don’'t actually know either of those games) is you want the camera just how it is in the third person template then press a key and detach it so it is over head like a drone. I think you likely want to switch from the player camera to the over head camera. You will probably do this in the level bp but I suppose it could be spawned too, just more of a pain to position.

Thanks for taking your time to answer! And looking at the video it’s exactly what I was looking for. I am still a bit lost with some of the nodes, like the input and output node for the clamping and the camera pawn and set nodes, how do i find those? How did you get the camera pawn component if I don’t have a camera component into the player blueprint, did you just drag and drop the camera pawn blueprint into it?

Would you also be able to show the IMC input as well? As I have no idea what modifiers actually mean?

And would you have any tutorials or like recommendations on videos for a beginners to the nodes and logic, because at the moment I am mostly copying without understanding much what is going on, and that won’t get me far.

But thanks again!

You can place the clamp nodes and then select them (by either dragging the mouse over them or clicking on them while holding Ctrl), right click on them (not on a pin though), and select the Collapse Nodes option on the menu that pops up. You can then double click on the newly created collapsed graph, click on the Inputs / Outputs node, navigate to the Details window while one of them is selected, and add new float type input & output pins. But you don’t have to do this, it was just for organization purposes.

Right click on the Return Value of the Spawn Actor node and select the Promote to Variable option on the menu that pops up.

Like I explained here :point_down:

The camera will be it’s own actor. You should add a camera component to the pawn class blueprint that we will dedicate to the camera. You can do it by navigating to the Components window, clicking on the Add button with a green plus icon on it, searching for camera and selecting the camera component.

  • IA Move is an Axis 2D (Vector 2D) type Input Action. From the IMC, one of it’s keys has no modifiers (in this case, the right movement key which is D), one is negated (the left movement key which is A), one is swizzled (the forward movement key which is W), and one is both swizzled and negated (the backward movement key which is S). If you choose to have no modifiers for the forward movement key (W), negate the backward movement key (S), swizzle the right movement key (D), and both swizzle and negate the left movement key (A), then you’d need to change the World Direction pin of the Add Movement Input node which the Action Value X pin of IA Move is plugged in to (x = 1, y = 0, z = 0) and the one Action Value Y is plugged in to (x = 0, y = 1, z = 0).

  • IA Drag is an Axis 2D (Vector 2D) type Input Action. From the IMC, it’s binded to Mouse X & Y 2D Axis and it’s values are negated. You can select that control by clicking on the dropdown menu next to the keyboard / mouse / controller icon, expanding the Mouse option and selecting it under there.

  • IA Zoom is an Axis 1D (Float) type Input Action. It’s binded to Mouse Wheel Axis and no modifiers are added.

  • IA Lock is a Bool type Input Action. No modifiers added.

You can add modifiers to the input action keys from the IMC by first adding them as mappings, adding them new control bindings, expanding the mapped key and clicking on the plus (+) icon next to the Modifiers text like this:

Screenshot 2024-12-27 132655

Here’s the most basic course out there. Not sure if there are tutorials dedicated to how nodes work though. There is actually kind of a tutorial series called “WTF is a [insert node name]” but they’re obviously separate videos for a tons of nodes.


If you have any more personal, specific questions, we can move the conversation to Discord if you like.

Cheers!

Hey @Kassmania, we haven’t heard back from you for a while. Let us know if you have any further questions :blush: