playMaker

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

Aaddiction

  • Full Member
  • ***
  • Posts: 166
Drag a rigidbody across the screen.
« on: March 25, 2014, 02:13:43 PM »
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, 02:18:58 PM by Lockon302 »

Aaddiction

  • Full Member
  • ***
  • Posts: 166
Re: Drag a rigidbody across the screen.
« Reply #1 on: March 26, 2014, 03: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, 07:11:05 AM by Lockon302 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drag a rigidbody across the screen.
« Reply #2 on: July 17, 2014, 02:16:58 PM »
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