how to change object position by mouse position

Get help using Construct 2

Post » Fri Jul 03, 2015 9:29 pm

hi everyone. i make top down shooter game. the hero in my game have a robot that can shoot.
i want to make that when the mouse is on left side from the hero the robot will be on the left side from the hero
and when the mouse is on right side from the hero the robot will be on the right side from the hero
B
8
S
3
Posts: 100
Reputation: 1,023

Post » Fri Jul 03, 2015 11:55 pm

Hey danul,

You can make an event that compares the X of the touch/mouse postion. It looks like this:

Condition: Hero X < Mouse.X
Action: Hero set X to Hero.X+1

Condition: Hero X > Mouse.X
Action: Hero set X to Hero.X-1

Once you have that working you can tweak it a little bit so its not so jerky. Maybe you would only make him move when the Hero.X is greater than the Mouse.X + 5.
ImageImage
B
128
S
23
G
7
Posts: 1,076
Reputation: 13,226

Post » Sat Jul 04, 2015 4:33 am

GenkiGenga wrote:Hey danul,

You can make an event that compares the X of the touch/mouse postion. It looks like this:

Condition: Hero X < Mouse.X
Action: Hero set X to Hero.X+1

Condition: Hero X > Mouse.X
Action: Hero set X to Hero.X-1

Once you have that working you can tweak it a little bit so its not so jerky. Maybe you would only make him move when the Hero.X is greater than the Mouse.X + 5.


thank you so much :D its worked
B
8
S
3
Posts: 100
Reputation: 1,023


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 6 guests