How to move things when there are in path of a swipe gesture?

Hi,

In my game there are moving objects that player has to move into some zones and currentyl it works fine with gameUI’s drag code. But I noticed some people swipe starting before the object and across over it and want it to move according to their swipe direction.

So is it possible to do?

So I want to be able to detect if a swipe collided with any number of objects and move them with the direction of the swipe.

Thanks.

Hi Aidin,

So if I understand, you want to “swipe-move” objects, but sometimes the user doesn’t begin the touch on the actual object, but rather, outside of it? Then they swipe over and you want the object to “attach” to that swipe gesture?

Yes, it can either “attach” to the swipe or get an impulse from the swipe. Idea is to move by the direciton of swipe.

Any idea how to do so?

Hi Aidin,

Sorry for the delay. This is still possible, but it’s a bit more tricky than I had initially thought. What I think you must do is keep a sort of “vector” during the swipe, i.e. you keep track of the current touch point (easy) but also the last 10 or so touch points behind it. This way, you can calculate a sort of directional vector when the swipe touches the object… and you can use that to apply an impulse in that direction (from the point it hits at).

Would that work in your scenario?

Brent

Hi Aidin,

So if I understand, you want to “swipe-move” objects, but sometimes the user doesn’t begin the touch on the actual object, but rather, outside of it? Then they swipe over and you want the object to “attach” to that swipe gesture?

Yes, it can either “attach” to the swipe or get an impulse from the swipe. Idea is to move by the direciton of swipe.

Any idea how to do so?

Hi Aidin,

Sorry for the delay. This is still possible, but it’s a bit more tricky than I had initially thought. What I think you must do is keep a sort of “vector” during the swipe, i.e. you keep track of the current touch point (easy) but also the last 10 or so touch points behind it. This way, you can calculate a sort of directional vector when the swipe touches the object… and you can use that to apply an impulse in that direction (from the point it hits at).

Would that work in your scenario?

Brent