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 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
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 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!
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
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:
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
Thanks again for the detailed answers! Haven’t been home for the past few days so haven’t been able to implement what you wrote yet, but will for sure reply once that is done
Hi again! Have been busy with stuff so couldn’t get back to this project for a while. I got a few more questions, so first one is what nodes are the Set Flow control nodes in picture 2 and 3. And how do I set up the camera in the viewport, gamemode and controller BP? I think I followed your steps correctly in the event graphs (except for the missing nodes), my pawn camera has a spring arm and a child camera, while my player has a sphere for now., both in the outliner with the camera set to autopossess player 0, but when i press play the camera jumps to the origin of the world.
I wouldn’t mind taking this to discord if it would make things more convenient
Hey @Kassmania, it’s great to see you back!
It’s just an int type variable that I named “Flow Control”, to control the execution flow using the Switch on Int
node.
After adding a camera component from the Components window of a separate pawn class blueprint, you can click on it and either hit E on your keyboard or click on the icon of two curved arrows making up a circle at the top of the viewport like this:
Now you can rotate it around Y axis by dragging the green circle around it that just appeared. You could also adjust it’s rotation by navigating to the Details window while having the camera selected and editing it’s rotatation property under the transformation section.
You don’t need to create your own for this specific task.
Maybe you have a use for it in mind, but a spring arm isn’t necessary here.
No no, the player character should be possessed by the player controller, not the camera pawn.
Sure! You can share your username with me via the private messages on this platform if you like
Sent you a message now I think