How do I make a sprite face wherever i touch?

Get help using Construct 2

Post » Wed Oct 05, 2016 8:50 am

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??
Last edited by johnkx on Wed Oct 05, 2016 9:05 am, edited 1 time in total.
B
48
S
20
G
6
Posts: 71
Reputation: 6,470

Post » Wed Oct 05, 2016 8:58 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Wed Oct 05, 2016 9:05 am

@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
B
48
S
20
G
6
Posts: 71
Reputation: 6,470

Post » Wed Oct 05, 2016 9:18 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Wed Oct 05, 2016 9:28 am

@Kyatric ok, thank you for explaining, i'll try to work it out! ;)
B
48
S
20
G
6
Posts: 71
Reputation: 6,470

Post » Wed Oct 05, 2016 9:39 am

@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..?
B
48
S
20
G
6
Posts: 71
Reputation: 6,470

Post » Wed Oct 05, 2016 11:18 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487


Return to How do I....?

Who is online

Users browsing this forum: bluesun66 and 2 guests