0 votes
func get_drag_data(position: Vector2) -> Control:
var preview : Control = load(get_parent().filename).instance()
preview.modulate = Color(1, 1, 1, .7)
var parent : Control = owner
return parent

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

in Engine by (73 points)

1 Answer

0 votes

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
by (313 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.