Move on grid to touch

DuesDues Member Posts: 1,159
edited June 2014 in Working with GS (Mac)

Hey guys!

Is it possible to make an actor move (the closest way) to where i click when that actor is on a grid?
Or is that logic going to be crazy hard to do? :)

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2014

    As an example, if you want the grid size to be 100:

    When Mouse Button is Down MoveTo x=round(game.Mouse.Position.X/100)*100 y=round(game.Mouse.Position.Y/100)*100
    Make sure it's set to relative to Scene.

    This would also require you to hold down the mouse button but you could change the code so that when you click it stores the mouse x and y positions and then executes the MoveTo after that.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
  • SocksSocks London, UK.Member Posts: 12,822

    If you split the X and Y movements, have one trigger on the completion of the other, it looks a lot more 'gridy' (is that even word ?).

    Link: https://www.mediafire.com/?hea599ea31e5l3c

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks ah... move along a grid. I didn't read it that way but I think you're probably right.

  • DuesDues Member Posts: 1,159

    @Socks‌ @tatiang‌
    Thanks! I will test this! :)

  • DuesDues Member Posts: 1,159

    @Socks‌ @tatiang‌ this worked perfect!
    Couple of more questions if you don´t mind :)

    Is it possible to make the actor slide on this grid using touch?

    Or maybe make it work with this?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2014

    That video is of one of my favorite demos. I actually made a 3D maze game that uses a similar concept to built the mazes. The only problem with the demo is that (if I remember correctly) it uses Interpolate behaviors to slide the actor, which means that collision rules won't respond properly.

    If you need that demo file, let me know. I didn't make it but I have it in my Dropbox account.

    Edit: Here it is: http://www.deepblueapps.com/collisions-with-tables-template/

  • DuesDues Member Posts: 1,159

    @tatiang‌ thanks! I just got that demo it's really cool!. Im trying to figure out how to make that actor slide with swipe instead of using the arrow keys. Any suggestions on that?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Just a suggestion to Google swipe GameSalad ;)

Sign In or Register to comment.