Have character face mouse cursor independent of movement key

Get help using Construct 2

Post » Tue Jan 31, 2017 9:31 pm

I have a character that uses the template for WASD movement. So he moves right/left etc. But I want him to always look in the direction where the mouse is (left or right) on a platform game.

So if I press A key to move left and have mouse cursor on the right side he should go backwards.

Right now he faces the way you press the keyboard.

How do I do this?
B
4
S
1
Posts: 5
Reputation: 312

Post » Tue Jan 31, 2017 10:11 pm

In the 8 direction properties (you're using 8 direction behavior right?), turn off the "set angle" property. Then add an event: every tick, set player angle towards mouse.x, mouse.y.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Wed Feb 01, 2017 4:58 pm

That makes my character look up and down and hes being rotated. I just want him to look left and right.

If the mouse is on left side he should be mirrored and right side normal.

If you played Starbound, the same way.
B
4
S
1
Posts: 5
Reputation: 312

Post » Wed Feb 01, 2017 5:18 pm

Zyme wrote:That makes my character look up and down and hes being rotated. I just want him to look left and right.

If the mouse is on left side he should be mirrored and right side normal.

If you played Starbound, the same way.


Then simply change the character animation [or width to negative] depending on the x coordinates of your mouse and sprite.

mouse.x > sprite.x | sprite faces right [or set width to default width]
mouse.x < sprite.x | sprite faces left [or set width to negative default width]
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests