playMaker

Author Topic: Help with dragging a 2D Sprite  (Read 2277 times)

Rapkannibale

  • Playmaker Newbie
  • *
  • Posts: 2
Help with dragging a 2D Sprite
« on: February 25, 2014, 07:18:09 AM »
EDIT: I found my error. I needed to use the ScreenToWorldPoint action in order to convert the screen position of the mouse to the world position.

Hello,

I am fairly new to PlayMaker and Unity so there may just be something obvious I am missing, but I would really appreciate some help with this problem.

I have set up a scene with a 2D sprite. The Sprite has a 2D Box Collider attached to it.

I have set up the following FSM


In the Idle state I have a Mouse 2D Pick action that sends the Mouse_Click event for Mouse Up and the Mouse_Drag event for Mouse Down.

Then you can see from the screenshot what I am trying to do in the Drag Hero Sprite state.

However, when I run it and hold the mouse button down on the sprite, it jumps to the centre of the screen, and then I can drag it around but only with a very limited range and not really following the mouse.

I tried unchecking the "normalise" box for the Get Mouse X and Y actions, but that just makes the sprite jump out of view.

Any help and advice would be greatly appreciated.

Thanks!
« Last Edit: February 25, 2014, 08:28:46 AM by Rapkannibale »

Phillament

  • Playmaker Newbie
  • *
  • Posts: 44
Re: Help with dragging a 2D Sprite
« Reply #1 on: February 25, 2014, 05:41:00 PM »
So I too was trying to figure this problem out, and this is what I came up with.
My example is 3D, so you may need to make some adjustments, but I can't say for sure.

I hope it helps! :)