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).
answered Jun 01 '14 at 09:50 PM
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. https://www.youtube.com/watch?v=GWbd0Wowwnk
Follow this question
Once you sign in you will be able to subscribe for any updates here