Touch Swipe Function


#1

What code could I use for a touch swipe function? Such as swipe left / right ? Particuarly one that works when over a particular object.

Any ideas?


#2

Hi There,

Swipe functionality would be best implemented using the pointermove event emitted by planes to track the user’s finger across it.

Thanks,
Mark


#3

Thanks Mark,

Any further advice on putting together the swipe script then?

Basically the script will need to check if the current pointer is further x than the primary pointer…and also further y than primary pointer.


#4

In general, you’re looking to track the x and y position of the primary pointer as you mentioned and then use a threshold value (minimum distance that needs to be covered) to determine if the user has swiped or not.

You can use a variable to store the last x and y position of the primary pointer and use that to compare to the current position to be able to determine the difference and compare it to the threshold value you set.

Hope this helps :slight_smile:


#5

Thanks. I’ll try and find some time to think through all that and develop something.

If you guys at Zappar ever feel like putting together a documentation for the above though, that would be amazing! I think swipe touch is a pretty basic / expected featured nowadays and it would be nice to have an documentation ref on the main Zappar website.


#6

We’re always looking to add more tutorials and templates to help with Studio, thanks for your feedback :slight_smile:


#7

A tutorial would be awesome showing how to create this feature :slight_smile:


#8

Hi. I urgently need help with something similar to this. I have a 3D object in ZapWorks Studio, that I have on my tracking image, and it shows up on the tracking image, and basically everything is fine with that. Bu I would like to try something a bit tougher, and I was trying to make it so if I tap the screen I can change the visibility of the object. For example, if I tap, I want it to disappear, and if I tap again, I want it to re appear. I looked at tutorials where I could do this with the pointerdown script on a plane, but there is not available pointerdown script for 3d objects. Any help would be appreciated, as I am a beginner.


#9

3D objects don’t currently support pointer events because of the computational expense it would take to calculate if/where on the model’s surface the pointer event occurred.

The workaround we suggest is to use a plane placed on top of the 3d model and made invisible as discussed at the beginning of this topic - 3D Object: Link, action, event etc by touch it

Thanks,
Mark


#10

Thanks! I will try that, hopefully it works. Btw, I think it would be great if you guys could work towards supporting pointerdown on 3d models. :grinning:


#11

Do you have any sample script for swipe functionality?
If yes, Can you please share it here…


#12

Hi there,

Unfortunately we don’t have a script to share.

As mentioned previously by Mark, you’ll want to make use of the ‘pointermove’ event which is emitted by planes to track the user’s finger across it.

If you’d like to see an example of how this functionality is implemented, feel free to have a look at our 3D photo feature template which makes use of them.

You’ll need to head into the ‘onScreenObject’ subsymbol found within the photo feature symbol. The pointer functionality code can be found within the ‘script’ node.

All the best,
Seb


#13

Hello Sebastian,

Thank you for the reference. I will have a look.
I am just looking for a simple swipe functionality to swipe left or right…

I figured out something basic to swipe left or right. but its not reliable. I mean it works only sometimes…

Do you have any suggestions to make it more accurate?

Thanks,
Sankalp


#14

May I ask if there is more information on how to pass variables about position? If I use the e.localposition to store the variable as an array, how can I pass that to other variables such as plane.position();


#15

@sankalpjagtap apologies for the delayed response but unfortunately we can’t offer project-specific advice. While we look to template some of the basic touch functionality the 3D Photo Feature subsymbol is the best place to look in the meantime as mentioned previously.

@donnav you’re looking for the position setter of a node. If you drag the plane you’re looking to alter the position of into your script node and insert it as a variable you can use the position setter on that.