How do I move my object on a grid to another location via the mouse?

0 favourites
  • 2 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hi there,

    I am stuck on how to make a object move on a grid like the one below which is a 64x64 constructs default grid which I made visible.

    I want to click on the pink square object then move the mouse along the single empty white squares to the blue square. Then once I click on the blue square I want the pink square to move to it via the white grid squares.

    Below is what I think I need to do, but don't know how exactly.

    As you can see in the event sheet I have made a global variable for a grid size which is 64 but then don't know how to implement in the events, or even if I have to make this variable? When I select the pink square it glows with a blue light, this works as it shows I selected the square.

    So once I select the pink square I need to get the mouse position first correct? So x and y position of the mouse. Then when I move the mouse cursor to a empty square, I want it to glow purple for example. So I need create a sprite which is purple and call it in events to glow when the mouse is over it right?

    As I said above, I want a grid type movement one square at a time moving to a specific location like the blue square, not go straight to the blue square like I did in the events below.

    Do I need to use tile movement behaviour? bullet? pathfinding? Or do I have to make a grid my self with the global variable and call it in the events?

    Can I not use the tile movement behaviour where I set grid size to 64x64 same as the default construct grid and do it in the events? And how would I do this? I tried a few things nothing worked.

    Any help would be appreciated, thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Check this example:

    dropbox.com/s/thlw3sqw42u9t6y/MoveOnGrid.c3p

    If you need to draw a path on white cells with mouse, and then the sprite to follow it, this will be more difficult.

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