How can I add Pinch to zoom with touch?

I know there must be a way this is possible but It’s too hard to test this on mobile because I have to build it every time. What is the best way I could impliment this?

I already was able to get a camera to move around with a top down view of my level I just couldn’t get zooming in and out to work correctly. Get Input Touch State should be all I would need to impliment gestures like this but I still do not know how the math would work and the event graph quickly fills up with nodes when im attempting this. I thought I heard about gesture support coming to blueprints soon so is that something I should wait for?

Any help would be appreciated.

Hi, I am learning about setting up touch events myself so I ran into your question.
First I am including a screenshot of a simple blueprint setup for zoom in and zoom out using mouse wheel,
this is a screenshot from a character blueprint’s graph.
As for the pinch actions, on each touch event you would need to check if there are 2 locations(2 fingers) touched at same time,
if so then get both locations and calculate distance and put it into a new variable “Distance1”.
Then on next touch event (2 fingers) create “Distance2” variable and compare it to “Distance1”.
If is bigger or smaller would determine whether we’re zooming in or out. You could divide the distances to get a multiplier for setting the zoom , which is the TargetArmLength of the camera (its attached to camera).

Jurif Can u specify some doubts because i’m a newbie on blueprint
Can you specify what i"m marked in the attchment.? Is it variabiles? What type is it? Can you specify little detailed
Sorry for my bad english
Thanks in advance

Hi, I am including more screenshots,

Camera Boom is a Spring Arm Component , if you go to the components BP menu (screenshot1), you can see the setup, as you can see TopDownCameraComponent is a attached to Camera Boom,
which is the red line you see on the right side. This is basically the way you would setup a blueprint for a character,
in this case it is a catapult. If you change the settings for Camera Boom → Transform (location, rotation,scale), you are changing the distance from the catapult to the camera. Look at the Target Arm Length setting, this is what we are changing in the blueprint to simply zoom out or in if you increase or decrease that number.

The way you would get the Camera Boom (Spring Arm Component) on the EventGraph is shown on screenshot 2,
you just select the component from the variables list on the left side and drag it into the graph.

Then you would click and drag on the Camera Boom node and once you release it gives you a list of functions and variables that are somehow related to Camera Boom component, look under Variables -->Camera–> there you can find the Target Arm Length variables.

If you’d open examples with characters, you would see same setup for camera in the bluprint,
also this series of video tutorials includes a video, I don’t remember which one it is, where he created this same system with Camera Boom Spring Arm Component and attaches camera to it.

Thanks Jurif. Just One more questions, How to make character movement using pinch like when I pinch out it should go forward and pinch in it should come back. Like in this Video ( Real time Architecture (customization and touchscreen) - YouTube ) this was made in Unity. Thanks again

Well I’m sure there are examples on how to do that out there,
but the basic idea would be same , just that you want to affect the movement of character instead of camera distance.
I’m not promising anything, but if I’ll have some time in next few days I will make a blueprint example for that and post the answer with screenshots.

Thanks Jurif

I did all the math myself using examples from implimentations in actual code. It’s fast and has almost no performance hit even when using all the math in blueprints. Im not posting images

Not very helpful. Why accept your own answer without actually providing one?

This is two years old I really don’t know why i didn’t post any images but I no longer have the blueprint. Its really simple so I really just suggest people to try it for themselves.

I have not touched unreal in a while though, they probably added support for this already so this is probably irrelevant.

So helpful, thank you

My reputation is not high enough, but if I could, I would downvote this answer even more

1 Like