how to do a camera panning?

I’m doing a product configurator and I’m in the final stage of the camera, I can already rotate it in 360, have zoom in and zoom out and now I need camera panning, the idea is: the user clicks with the middle mouse button and safe to drag the screen up and down or left and right, I tried with these blueprints but it didn’t work


this is my blueprint, detail that is a pawn and the camera is on a spring arm

Hello,
I would have a solution for you, I just need to know if you are using the old input system or the new enhanced system (from 5.1)

I’m using the old in the 5.1

Here is the code for panning the camera. The idea is to move the camera on its own axis, the nodes for that are “get actor up axis” to go up/down and “get actor right vector” to go left/right.
If you prefer the camera to move on a plane instead, we will replace these nodes by a simple vector (like 0; 0; 1 for vertical and 1; 0; 0 for horizontal (may also be -1; 0; 0 or 0; 1; 0 or 0; -1; 0 depending if your scene is facing north, west, south or east)).

These are the inputs names I’m using :

Now the panning up (my panning speed is set to 10) :

And left/ right :

There is an other method for a smooth movement (interpolation on tick), tell me if you prefer. In this case it would be good to see your code for the rotation and zooming of the camera, everything can be smoothed.

2 Likes

here the blueprint for rotation and zoom

I use a spring arm, I can’t link it to get actor up to vector and location

and which node would that camera rotation yaw be? I didn’t find it, I’m new to unreal

“Camera rotation yaw” is simply a group of collapsed nodes. It is possible to select a group of nodes, right click and choose “Collapse nodes”. It is simply to arrange the blueprint.
At least on my picture you can see that if middle mouse is pressed, it does something, if not, it rotates camera on yaw, that was the purpose.

You can’t get actor up, forward or right vector on the spring arm since it is a component (there are equivalent nodes for components, but that is not what we need here).

Here is another picture without the confusing collapsed nodes so you can see better what is plugged on the branch. I also got rid of the “camera ref” now that I know better what you have done. Now the target of the nodes are simply “self”.
For the panning everything is done to the actor itself (by the way I’m using a character actor), I’m not doing anything to the spring arm or the camera :

I don’t want to over complexify things with the smoothness of panning and zooming for the moment if you don’t need it, however it is very easy to add it to the rotation. Simply check “enable camera rotation lag” on the springarm :

We can adjust behaviors later once you get it working.

Edit :
I forgot this one, you already have it but just in case :

2 Likes

did not work :frowning:

how i did

i create 2 more inputs, that’s right? i did it

image_2023-05-31_120936874

my bp is a pawn that is the character of the scene, if help

You didn’t need to create new inputs, in fact they may interfere. You already have your “Turn” input for panning left/right and rotate camera yaw, and you have your “LookUp” input for panning up/down and camera pitch. It is just that my inputs had different names, hence the confusion.
Use the one you want, but use only one for mouse X and one for mouse Y.
Don’t forget also to set default value for the variable “speed” (more than 0, 1 or 2 is a good value to start with) and “IsPanning” to false (but it was probably already the case).

Then I see also some nodes you didn’t copy correctly :

It helps to know it is a pawn, you have to check this option :

Fix the inputs and the nodes, check the option and tell me how it behaves

1 Like

It worked!!! Thank you very much, just one more question, the camera is rotating with any of the 3 mouse buttons (left, right and middle button), what makes it also rotate when I pan with middle button, how do I make it rotate with only one of the buttons and not the 3?

1 Like

Weird, it should not rotate with middle mouse button pressed.
If I understand correctly, you want to pan with middle mouse and rotate with left or right pressed ?
Simply create another boolean with your input :

and use it with a branch :

it worked when i put branch in rotation nodes, now it’s working well, thank you very much for your help, i was really searching for it :heart:

1 Like

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