Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Rapkannibale on February 25, 2014, 07:18:09 AM

Title: Help with dragging a 2D Sprite
Post by: Rapkannibale 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
(http://i.imgur.com/JeVwpT4.png)

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!
Title: Re: Help with dragging a 2D Sprite
Post by: Phillament 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! :)