playMaker

Author Topic: Drag a rigidbody across the screen.  (Read 926 times)

Aaddiction

  • Junior Playmaker
  • **
  • Posts: 85
    • View Profile
Drag a rigidbody across the screen.
« on: March 25, 2014, 11:13:43 AM »
Hi, I searched, but couldn't find an answer.
So I have a cube and I want to be able to drag it on x,y axis.

How could I make it work? I started by setting "Touch object event" to send an event when Touch Began, but what should be the next state? Transform.Translate most probably, but how to get the touch movement position and move the object accordingly?

EDIT: Just found that MouseClickToDrag is very similar, see if it works on mobile.

I guess this should also work on Android.
Thank you.
« Last Edit: March 25, 2014, 11:18:58 AM by Lockon302 »

Aaddiction

  • Junior Playmaker
  • **
  • Posts: 85
    • View Profile
Re: Drag a rigidbody across the screen.
« Reply #1 on: March 26, 2014, 12:40:49 AM »
I almost managed to get it working. I have two issues:

1. When I click on the object it lifts up. However I only want it to drag along x and z axis, not y. EDIT: Fixed by setting the y to 0 in the Set Position action.

2. How could I have two draggable objects in the scene - a cube and a sphere to drag individually?

Thank you.
« Last Edit: March 26, 2014, 04:11:05 AM by Lockon302 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Drag a rigidbody across the screen.
« Reply #2 on: July 17, 2014, 11:16:58 AM »
Hi,

 For this, you should have the logic implemented on each gameobjec that can be dragged, AND always save the fingerId of the finger that touched that gameobject so you get the touch infos of that fingerID, with this you can have multiple touch drags.

bye,

 Jean