how to change object position by mouse position

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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 its worked

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