Alternative To Draggable Behavior

When adding the draggable behavior to my sprite it doesn’t work so I want to make my sprite draggable through events
Does anybody know how to do this?

The draggable behavior is not working, or not working as you expect? Because it should work in both platforms :confused:

Anyway, to simulate the draggable behavior over an object, the idea is to “mark”(?) the object that is under the cursor when you press the mouse button, then move the marked object to the cursor position while the button is hold, finally unmark the object when the button is released:

[code]Conditions: Left button is pressed
Trigger once
Actions: No actions
// Sub-event
Conditions: Cursor is over DraggableObject
Actions: Do = 1 to the variable “dragging” of DraggableObject

Conditions: Variable “dragging” of DraggableObject is = 1
Actions: Do = MouseX(); MouseY() to the position of DraggableObject

Conditions: Left button is released
Actions: Do = 0 to the variable “dragging” of DraggableObject[/code]
If you want to know why I use a sub event here, please check this: [url]If clicked condition - #2 by Lizard-13]

This way the object will be placed (from its Origin point) exactly over the cursor position, so maybe you’ll want to add an “OffsetX” and “OffsetY” variables, that save the initial offset between the object position and the cursor, and add the offset while the object follow the cursor :wink:

1 Like

I figured it out yesterday
The draggable behavior works, what I wanted to say is that the draggable behavior and the physics behavior don’t work together

The Physics and Draggable behaviors don’t work very well together, not to say they don’t work together at all, I’ve tried to use the renowned “mouse joint” through C++/JS events, but no luck :frowning: