Snap drag preview

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By boruok
func get_drag_data(position: Vector2) -> Control:
var preview : Control = load(get_parent().filename).instance()
preview.modulate = Color(1, 1, 1, .7)
set_drag_preview(preview)
var parent : Control = owner
return parent

It’s is possible to snap to grid dragged preview?

:bust_in_silhouette: Reply From: MintSoda

Assume grid size is 40 x 40.

preview.position.x = round(preview.position.x / 40) * 40
preview.position.y = round(preview.position.y / 40) * 40

nope, that doesn’t work. I’m assuming that there is methods for snapping preview with get_drag_data method

boruok | 2021-09-05 01:06