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"

Getting screen resolution independent swipe/drag distance

I'm building a very simple basketball game where the player will launch a basketball based on a swipe/drag. I can get the start and end point of the swipe, as well as the time it took to complete. I use distance over time to get the speed and use that value to build a vector to launch the ball.

The problem I have is the following:

On a device with a resolution of 1280x720 the pixel distance of the swipe is different than on a device with a 1920x1080 resolution. On a device with a higher resolution, the player would have to do a much shorter swipe.

What I would like to do is get the screen resolution so I can divide the pixel distance by the screen height. That way it would work the same for any resolution.

So my question is:

  • Is there a way to get the screen resolution at runtime? The Viewport Size node only works in-editor.

  • Is there another or better way to get a resolution independent solution?

One thing I haven't tried but will give a shot is:

  • Parent a collider to the camera

  • Get the world space coordinates from the screen space location of the begin and end of the swipe

  • Use that distance to do the rest.

I'm guessing that way it would also work on any resolution, but somehow seems a bit hacky?

Product Version: UE 4.10
Tags:
more ▼

asked Dec 20 '15 at 03:55 PM in Blueprint Scripting

avatar image

nielsvaes
1 1 2

avatar image BillBeob Jan 12 '18 at 06:49 AM

Hi there, did you find a solution to your problem? And would you please mind sharing your solution, that woud be appreciated? Thanks

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

0 answers: sort voted first
Be the first one to answer this question
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