Pinch event - how does it work? Why is there no documentation?

Just thought I’d give an update.

As there didn’t seem to be an easy way of doing this, I figured I’d just bite the bullet and try my hand at writing the logic myself. It wasn’t too bad really. It’s always hard to look at other peoples code (including blueprints), so in the end I didn’t really try and mimic the code posted in this thread (although I’m sure some of the logic is the same).

The first problem I encountered however was that the inputtouch “pressed” did not register. “Released” was fine. I did a very simple test which was just connected to “print string” so I definitely didn’t make a faulty test case. In hindsight maybe this is because I think I selected to use the mouse for touch in the settings earlier. Although I haven’t confirmed that.

Anyway, for anyone interested, by logic was basically as follow:

  • on pinch event I simply set a variable to say that I was (or was not) pinching. Using the standard touch input when pressing finger 2 would probably work too (but as mentioned I had problems with that).
  • all the rest was driven from inputtouch move event. I basically just grabbed position of finger 1 and 2 and assigned to variables. Before grabbing this position, I assigned previous position to of finger 1 and 2 to different variables.
  • if all conditions are met (ie all variables where assigned and I was pinching etc) I calculated the x distance between finger 1 and finger 2. I then compared to distance between previous finger 1 and 2.
  • pending on whether difference of these two sums were positive or negative, I moved camera in or out using this value multiplied by a static variable (zoom speed). But only if it was over a certain threshold, to make it smoother. In other words, if I pinched very very slow, nothing would happen.
  • when pinching stopped, I also reset the finger position variables.

I think that’s basically it. Not very difficult logically, but the blueprints did end up surprisingly messy and it felt a bit hacky. But it worked very well, I couldn’t find any issue or annoyance whatsoever when testing. It worked exactly as I’d hoped.

Where should I put this logic though? It’s currently on the level, which isn’t right.