0 votes

Hi.
Tell me please how to make drag and drop physical objects (RigidBody2D)

I did, but I do not like the behavior of the body. I want to implement such a video.
https://youtu.be/QiLHc_zJNvA?t=2322

in Engine by (81 points)
edited by

2 Answers

0 votes
Best answer

Maybe someone will need.
I decided to do it:

var r = Vector2(getviewport().getmousepos() - getpos()) * speadDrag;
setlinearvelocity(r)

by (81 points)
selected by

ooh. thats a good idea!

0 votes

Under your if(Input.is_mouse_button_pressed()) try a line like this:

set_pos(Vector2(get_viewport().get_mouse_pos())

this will set the object to the vector current position of the mouse. Once you release the button, the object should continue it's physics as normal.

by (69 points)

I did, but I do not like the behavior of the body. I want to implement such a video.
https://youtu.be/QiLHc_zJNvA?t=2322

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 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 webmaster@godotengine.org with your username.