Move on grid to touch
Dues
Member Posts: 1,159
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
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.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here's a demo: https://www.dropbox.com/s/bgx2ow8jwcybcpw/Move snap to grid.zip
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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
@Socks ah... move along a grid. I didn't read it that way but I think you're probably right.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@Socks @tatiang
Thanks! I will test this!
@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?
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/
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@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?
Just a suggestion to Google swipe GameSalad
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User