Taking my first steps with this awesome tool, any help would be appreciated.
How do you implement drag and drop control with your mouse?
I put a rigidbody collider and an interaction machine on the game object I wish to drag.
Then, what do I put down in the schematic?
Am I missing any other necessary steps?
Thanks,
Gordon
- Using mouse position change:
You can get the mouse delta (i.e. position change since last frame) with the Mouse Touch Delta node, which stores the values into a Vector3 variable (X-axis being horizontal, Y-axis being vertical change).
Now you'd use those values to change the position of the cube with one of the movement nodes.
- Using raycasting:
Use a Raycast node to find the position of the mouse in your scene, e.g. having the ground on its own layer helps to only check the ground and not other objecs. Now you can just place the object at that position (e.g. using a Change Position node), or manipulate the found position before placing the object (e.g. adding an offset or keeping the original Y-position of the object).
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I'm still having difficulties getting the object movement synchronized with mouse movement. Could you be more specific how to configure the move node settings?
I can almost get it to work, but then either the object moves faster than the mouse, or it becomes jumpy and jittery in the process. I'm sure all the settings make sense when trying to configure more advanced moves, but I'm really looking for the simple and classic drag and drop :-)
It's far easier using the raycast approach - all you need is a Raycast node using the Screen raycast origin and Use Mouse Position enabled. Limit the layer mask to your ground layer (or some kind of invisible plane in your scene) and store the hit point into a local variable.
On Success, use a Change Position node to set the object's position to the stored variable.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Mouse moves the object but only a tiny distance and not full mouse movement.
I tried playing with "normalize" and "local position" but results were jittery and jumpy.
Here's some screenshots, am I doing it wrong?
Alternatively, you can enable Move and use a short move time (e.g. 0.1 or 0.01) to smooth the movement.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
However, I noticed that when I move my mouse fast enough, it "escapes" from the dragging interaction and stops moving. Is there a way to circumvent this so it will never stop dragging while mouse/touch is held?
Thanks again for your help and patience, it has strengthened my confidence in this framework as a viable development tool.
Gordon
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Maybe using the delta instead, or doing it in Late Update (tick machine) gets better results.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!