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"

Touch Input Vector Position

Hello guys!

I'm having some trouble on setting my touch input. I'm trying to make an object move with a touch swipe, but, I'm not achieving it. As you can see by the print, the problem seems to be in my touch input.

My object appears with X and Y coordinates negative, while my input is with both of them positive. At this time, I was clicking right above the object.

Also, when I swipe up, for exemple, my object moves to the left, like his pivot is rotated. I've verified it and it's not.

It's meant to be an android game.

Can anyone help me with that? There is also a print of my code where i get my click's position.

alt text

alt text

Thx.

Product Version: UE 4.19
Tags:
positions.png (167.4 kB)
code.png (110.0 kB)
more ▼

asked May 25 '18 at 01:45 AM in Blueprint Scripting

avatar image

Tabacudo
62 3 5 13

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

1 answer: sort voted first

Original mouse position uses screen coordinates, while object position uses world coordinates.

So you should get mouse / touch position, convert it from screen to world - this returns location on near clip plane. Then you must add some offset vector, to move it on desired height. Then apply result location to object.

Some time ago I have experimented with game like this. I used trace result under finger and collision box to get desired location in world, to place aircraft. But maybe you can find other way to convert screen location to desired world location on specific height (Z).

more ▼

answered May 25 '18 at 05:31 AM

avatar image

redbox
4.3k 81 19 104

avatar image Tabacudo May 25 '18 at 03:56 PM

Wow! I'd never guess that.

I solved the problem getting the click position and using the "Convert Screen Location To World Space" node. It's working really fine.

Thank you! :D

(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