follow touch

0 favourites
  • 10 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I would like my player sprite to go to the finger on touch so that it can be moved without buttons. So wherever the finger touches, the sprite will "walk" to it.

    Here is my code. Any suggestions on why this is not working correctly?

    <img src="" border="0" />

  • just do this instead:

    On touch

    --> set player.x = touch.x

    --> set player.y = touch.y

  • Thanks very much! That works well she goes all around and follows my finger but now there are 2 new problems...

    She goes through solid objects & she flips and flops all around. She looks like a person so sometimes she flips to stand on her head or spins and it looks crazy. I know that's the angle, etc and can probably eventually fix it but what about stopping her from following my finger through solids?

    She is set to "collisions enabled" and her bullet set to bounce off solids.

  • Her angle stays straight with the keyboard controls. I hope by fixing her to stay straight with touch it doesn't ruin that?

  • I made a small maze example at some point using the line-of-sight behavior. That could be used.


    You could set the angle to 0 when you set the x and y as well.

    argh.. wth... like this <img src="smileys/smiley1.gif" border="0" align="middle">   .capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wow the lab3 sample helped me so much!! Now she moves perfectly :) Now just to figure out how to get her to know which way she's going so to set her animation. Thanks so much for your help.

  • A lab4 for you then <img src="smileys/smiley1.gif" border="0" align="middle">

    The distance thing is to stop it from doing a "jitter"


    Try to disable it and you will see the difference.

  • Okay I have modified the lab4 code a little bit to fit my purpose. My sprite is transparent "Player" with pin for "Player Animations". She is still not flipping to face her direction so I'm not sure what I've done wrong cvp? Here is my new code now

    <img src="" border="0" />

  • You need to remove the two event actions you have in the "is in touch"

    In lab 4 they were moved to the bottom. (you can see you have them twice now)

    <img src="" border="0" />

    The reason why yours will not change face direction is because as your code looks now you are setting the position of the player before your check the distance. So the distance will always be 0.

    Thats why the Set position and angle was but down at the end.

  • Ah of course!! You've taught me a lot thanks so much again. I know this thread will come in handy for others too.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)