{"id":1695,"date":"2025-11-24T14:20:42","date_gmt":"2025-11-24T14:20:42","guid":{"rendered":"https:\/\/sites.wsagames.com\/pe1n23\/?p=1695"},"modified":"2026-01-12T14:56:32","modified_gmt":"2026-01-12T14:56:32","slug":"godot-prototyping-2","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/pe1n23\/godot-prototyping-2\/","title":{"rendered":"Godot Prototyping 2"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Dragging and Dropping<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After my successful experiments with adding basic rhythm elements to the game, I now wanted to implement a system of dragging the different &#8220;blocks&#8221; in to make the beat on a sequencer-esque grid as per the idea I had in the previous blog. I used the following video as a guide on how to implement this:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Godot 4 Drag-and-Drop Tutorial: Create Interactive Games with Ease\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/uhgswVkYp0o?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Checking for player clicking and dragging is very simple in Godot as the Area2D node can give off signals whenever the mouse enters or exits it. However, a global variable for whether the player is dragging something must also be set so as to make sure they can&#8217;t grab anything else, and that they are allowed to drop items in Droppable areas.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1383\" height=\"199\" src=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-11.png\" alt=\"\" class=\"wp-image-1700\" style=\"width:1029px;height:auto\" srcset=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-11.png 1383w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-11-300x43.png 300w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-11-1024x147.png 1024w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-11-768x111.png 768w\" sizes=\"(max-width: 1383px) 100vw, 1383px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The code above also sets an &#8220;offset&#8221; based on where the player clicked the DraggableObject, so it doesn&#8217;t immediately snap to their cursor.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"874\" height=\"102\" src=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-12.png\" alt=\"\" class=\"wp-image-1702\" srcset=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-12.png 874w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-12-300x35.png 300w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-12-768x90.png 768w\" sizes=\"(max-width: 874px) 100vw, 874px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The code here is responsible for moving the object when it is dragged.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After this I made three DraggableObject objects, with one resized, and six Droppable objects in the main Game scene\/object:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1017\" height=\"622\" src=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/IMG-20251122-WA0000.jpg\" alt=\"\" class=\"wp-image-1705\" srcset=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/IMG-20251122-WA0000.jpg 1017w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/IMG-20251122-WA0000-300x183.jpg 300w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/IMG-20251122-WA0000-768x470.jpg 768w\" sizes=\"(max-width: 1017px) 100vw, 1017px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This worked fine as a proof of concept for how the blocks would fit together for those unfamiliar with a drum machine or sequencer:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"647\" src=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-15-1024x647.png\" alt=\"\" class=\"wp-image-1708\" srcset=\"https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-15-1024x647.png 1024w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-15-300x190.png 300w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-15-768x485.png 768w, https:\/\/sites.wsagames.com\/pe1n23\/wp-content\/uploads\/sites\/10\/2026\/01\/image-15.png 1105w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Dragging and Dropping After my successful experiments with adding basic rhythm elements to the game, I now wanted to implement a system of dragging the different &#8220;blocks&#8221; in to make the beat on a sequencer-esque grid as per the idea I had in the previous blog. I used the following video as a guide on [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":1705,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-1695","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-year-3"],"_links":{"self":[{"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/posts\/1695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/comments?post=1695"}],"version-history":[{"count":4,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/posts\/1695\/revisions"}],"predecessor-version":[{"id":1709,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/posts\/1695\/revisions\/1709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/media\/1705"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/media?parent=1695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/categories?post=1695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/pe1n23\/wp-json\/wp\/v2\/tags?post=1695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}