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"

Createing a touch and drag interface in the 3d world

I am trying to create a 3d card game for mobile devices. Currently I am in the process of creating an interface to move playing cards through 3d space in the game using a touch screen. When I get the value of the touch input it gives me a 2d vector based on the screen and I can convert that vector to real 3d space. The problem is I had to offset the values I get from the input to match the true location in the game. This presents a problem for multiple sized screens. So far here are the numbers I am working with....

Screen (width / height): 905/431
Current Offset (width / height): 250/183
Movement Variance: 22

The movement variance is the number of units the card moves in real 3d for every one unit of touch. I need to find some sort of calculation to scale these values to any screen size but I am stumped. I will add some pictures to help make sense of this.

Game Board

Full Code Snippet

Precise Code Snippet

I would appreciate any input. Including a better way to use a touch interface all together. I would have imagined an easier to use touch interface system but I guess not. Maybe some way to actually link to 3d space built into the editor. I can get it to work fine on any one specific size but I need a way to scale it no matter what device people play on. If there is no way to scale accurately I guess I can use a table of values but lets try to avoid that...

Product Version: UE 4.10
capture3.png (583.6 kB)
capture.png (203.4 kB)
capture1.png (264.6 kB)
more ▼

asked Dec 18 '15 at 05:43 AM in Blueprint Scripting

avatar image

1 1 1 1

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

1 answer: sort voted first

I do everything in world space instead of screen space.

The first step is in my player controller, I use the input touch event. When it is pressed, I take the hit from Get Hit Result Under Finger By Channel, then I break the hit, and cast the hit actor to my object to be dragged (in your case this would probably be a card actor base class) If the cast succeeds, then I know the user touched the object to be dragged (in your case a card) and I set a dragging bool to true (this gets set to false on touch release of course) lastly, I set a reference variable for the dragging object (you can get this from your broken hit, hit actor)

Then in the tick event (I also do this in the player controller), if the dragging bool is true, I simply set the actor location of the dragging object to the location of the broken hit. This may not be needed for you, but I also break the location vector and strip out the Z value, and replace it with a hard coded value so everything always stays on the same plane.

Hope this helps!

more ▼

answered Dec 31 '15 at 06:41 AM

avatar image

26 5 12 10

(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