Hello, it has been long since I have used Gdevelop. So I am gonna start again with something very basic.
How do I make an object attach to the mouse cursor without using ‘Draggable’?
I have tried a few things but it does not work the way I expect, because I am probably missing something crucial here.
~When we click on an object, it should follow the mouse cursor (stick to it).
~When we click again, it should detach the object and place it wherever the mouse position was at the moment of detach.
I must mention that, I have tried ‘Draggable’ behavior, but it does not fulfill my exact requirement. In draggable behavior one must hold the mouse button to drag the object. On the other hand, I need the object to stick to the mouse cursor by just clicking once. Then detach it by clicking once again.
When run, the Circle object keeps attached, but then it stays attached after clicking the mouse. I have a feeling that I may be missing something very basic here, but cannot figure it out. Have been trying various other combinations. One such try goes like this:
When run, as DragMeAround is initially false, I click the Circle once. It snaps to the mouse position but does not stick. Although strangely when the mouse button is held and dragged on the object, the Circle gets dragged along. So back to initial problem.
As far as my understanding of Gdevelop event system goes, I think that second event mouse click and third event mouse click is happening at the same time and the true/false condition is met simultaneously.
Gruk’s reply made me realized how little I know applying logic in general, as well as Gdevelop. So first I had to get my fundamentals right. It works in different ways when it comes to certain patterns. And I understood that it was crucial to know those differences.
Big thanks to Gruk as I wasn’t aware of things like ‘toggle the boolean’. Heck I didn’t even know the scope of ‘Trigger Once’. Well, now I am beginning to understand these basics and applying them to my practice-logics.
Although it still took me a while to figure this one out but here is the solution just in case anyone else is interested. Took me like forever to come up with the last event-line but then it was Eureka moment.