How Can I Launch A Character With A Swipe Against It In Any Direction?

Discussion in 'How Can I...?' started by Jackaboy, Jun 23, 2019.

  1. Jackaboy

    Jackaboy Boxer

    Joined:
    Jun 22, 2019
    Messages:
    1
    Likes Received:
    0
    I want to make a platformer game where you can launch the character in any direction, a ball, by swiping against it. But there are two problems I am having with this:
    1. As far as I know, one can only control the character using swipes that go up, down, left, and right. Is there a way to control the character with, for a example, a 70 degree swipe or a 120 degree swipe?
    2. I only want the character to be launched in the direction of the swipe when the swipe actually hits it. As far as I can tell, the only way this would be possible is if I create an invisible physics object that follows the swipe and launchs the character when it collides with it. But I can't find a way to make the object follow the swipe. How would I do this?
     
  2. mamal

    mamal Boxer

    Joined:
    Jun 8, 2019
    Messages:
    43
    Likes Received:
    4
    ofcourse you can do,
    all you need is to record the position of where the touch has begun and where it has ended.
    take those parameters and then do some calculations on them that tells you about the direction and degre and then add speed to your character in that desired direction.
     
  3. Evert

    Evert Boxer

    Joined:
    Nov 15, 2018
    Messages:
    6
    Likes Received:
    0
    Do you have an example of how to do this? looking for the same thing. :)
     

Share This Page