x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Swipe motion accuracy

I am trying to use a swipe motion to launch an object in an arc. How can I factor in the accuracy of the swipe into the accuracy of the launch? Like if the swipe pulls right, the launch pulls right. If the swipe pulls left, launch pulls left. Swipe is dead straight, the launch is dead straight? Similar to the way like a Pokemon Go swipe works. I'm guessing I need to somehow read the swipe, then add some force or impulse to the velocity to get it to pull left or right. But I'm not sure how to read how the swipe behaves to translate it.

Product Version: UE 4.19
Tags:
more ▼

asked May 24 '18 at 06:02 PM in Blueprint Scripting

avatar image

DMHokie
68 15 26 36

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I don't know how to do swipe gestures in Unreal but I do know how to track the touch start location and the touch end location, and you can subtract one of those vectors from the other in order to get usable numbers, Y component of the vector is screen coordinate you can conceptualize as the forward or upward swipe motion, and X for the side to side.

It won't be a direct ratio between screen coords and world coords, especially at different screen resolutions though so you'll want to use some normalizing function nodes to make it work the same on all devices. Sorry I can't remember the names of them.

Whether you use that approach or not, you can find the deviation between two vectors (for example the straight dead-on direction toward the target and the direction the user swiped) by feeding them both into a dot product node.

Dot product takes two vectors and returns a value between -1 and 1, where 1 is exactly parallel, 0 is perpendicular and -1 means they face opposite directions.

more ▼

answered May 24 '18 at 07:08 PM

avatar image

mightyenigma
3.8k 18 23 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question