How do I make a sprite face wherever i touch?

0 favourites
  • 7 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi guys, as mention in the subject, I'm trying wherever i touch the screen, my player sprite would remain at its position and look at that direction, therefore I tried using set angle toward position (Touch.X, Touch.Y). The result was my player sprite automatically rotate to left for 90 degrees. Do anyone know how to solve this? Or is there a better solution??

  • Are you using the mouse input ?

    You mention using Touch. If so, you should be facing toward (Touch.X, Touch.Y), not (Mouse.X, Mouse.Y).

    Otherwise, consider posting your capx, simpler solution for us to investigate what is actually going on.

  • Kyatric, no I'm not using mouse input, i type wrong, I just correct it back, below is my sample cpax file.

    https://www.dropbox.com/s/56io2ckgi36qf ... .capx?dl=0

  • Instead of an "Every tick" event, use "Is in touch" from the "Touch" object. This way the angle will only be applied when there are coordinates to apply.

    When touch is not touching, Touch.X and Touch.Y are both 0, and your sprite faces this direction.

    This will possibly have its own set of consequences later on (if you are having an UI for example, you will want to prevent the sprite from facing that direction when clicking/touching the button). You will likely have to refine/add conditions to your event later on depending on the rest of your game.

  • Kyatric ok, thank you for explaining, i'll try to work it out!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kyatric , whenever I touch the screen after setting set angle toward position (Touch.X, Touch.Y), the sprite upper side(head) do not face where I touch, instead the right side of the sprite face where I touch, do you know why..?

  • Angle 0 in C2 is facing right.

    If you want the head of your character to be the facing part of your sprite, rotate the image in the image editor so that your character is horizontal and its head facing to the right.

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