playMaker

Author Topic: Drag object with snap?  (Read 4023 times)

gregbassett

  • Playmaker Newbie
  • *
  • Posts: 1
Drag object with snap?
« on: September 25, 2013, 11:29:21 AM »
There are many examples of using Playmaker to do dragging of objects in a scene at runtime, but how can you add snapping, like in the Unity Editor.

I am interested in implementing this using both mouse in webplayer, and finger on iOS or Android.

Any help greatly appreciated!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drag object with snap?
« Reply #1 on: September 26, 2013, 01:43:23 AM »
Hi,

 snapping is something you need to insert in between your touch input and the object itself.

 so instead of control the gameobject position, you control a variable. And then the snapping fsm will take that variable, snap it and then apply it to the gameobject as its final position.

 To snap values, well, I would definitly use a framework from the asset store. There are plenty. for example:

http://u3d.as/content/hi-phish/grid-framework/3bR


Study the doc, I think it holds what you need. you may likely find ready made components to do exactly what you need already.

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Drag object with snap?
« Reply #2 on: September 26, 2013, 03:12:20 AM »
Grid Framework works really well. If you're set on trying to do it in playmaker, I've got this to work but taking the Position of the Object, saving it as a float, converting it to an Integer (whole number), then saving it back to that float and setting the position of the object. So if you dropped your object at 1.2, 0, 1.4, it would become 1, 0, 1. But Grid Framework definitely is awesome and would save you the headache.