{"id":1930,"date":"2014-06-24T15:48:21","date_gmt":"2014-06-24T15:48:21","guid":{"rendered":"https:\/\/www.anagram.at\/en\/move-objects-in-blender-game-engine\/"},"modified":"2018-09-30T16:31:08","modified_gmt":"2018-09-30T16:31:08","slug":"move-objects-in-blender-game-engine","status":"publish","type":"post","link":"https:\/\/www.anagram.at\/en\/move-objects-in-blender-game-engine\/","title":{"rendered":"Move Objects in Blender Game Engine"},"content":{"rendered":"<p>This article describes a way to &#8220;pick and move objects&#8221; in <a href=\"http:\/\/blender.org\">Blender Game Engine<\/a>.<\/p>\n<p>Unfortunately a lot of published code is not working with the current version of Blender or depends on specific objects within the scene.<\/p>\n<p>I wrote the code to try some 3D Collision Shapes. In order to do that, i wanted to have the objects movable to see how they interact with other objects.<\/p>\n<p>Let me know if you see any improvements and leave a comment if it&#8217;s useful for you.<\/p>\n<p>The code does the following:<\/p>\n<ul>\n<li>pick an object with left or right mouse click<\/li>\n<li><span style=\"line-height: 1.5em;\">move it as long as the mouse is clicked, release it otherwise<\/span><\/li>\n<li><span style=\"line-height: 1.5em;\">move on x\/y plane with LMB, move on y\/z plane with RMB<\/span><\/li>\n<\/ul>\n<p>Currently i&#8217;m fine with moving them with 3DOF, so i can move them in X,Y and Z direction.<\/p>\n<p>I have written this little script, which is triggered by MouseOverAny, Left Mouse Button Click and Right Mouse Button Click.<\/p>\n<p>I&#8217;ve assigned the sensors to the camera, which i thought is probably the only object that will stay within the scene.<\/p>\n<pre>import bge\r\n\r\ncont = bge.logic.getCurrentController()\r\nLMB = cont.sensors[\"LMB\"]\r\nRMB = cont.sensors[\"RMB\"]\r\nif LMB.positive | RMB.positive:    \r\n    mouseOver = cont.sensors[\"MouseOver\"]\r\n    obj = mouseOver.hitObject\r\n    mouseX = mouseOver.hitPosition[0]\r\n    mouseY = mouseOver.hitPosition[1]\r\n    mouseZ = mouseOver.hitPosition[2]\r\n\r\n    if LMB.positive: \r\n        obj.position[0] = mouseX\r\n        obj.position[1] = mouseY\r\n    if RMB.positive:\r\n        obj.position[1] = mouseY\r\n        obj.position[2] = mouseZ<\/pre>\n<p>The assignments can be seen here:<\/p>\n<p><a  href=\"https:\/\/www.anagram.at\/app\/uploads\/2014\/06\/BlenderMovingObjectsLogicEditor.jpg\" data-rel=\"lightbox-gallery-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-1409\" alt=\"BlenderMovingObjectsLogicEditor\" src=\"https:\/\/www.anagram.at\/app\/uploads\/2014\/06\/BlenderMovingObjectsLogicEditor-300x191.jpg\" width=\"300\" height=\"191\" srcset=\"https:\/\/www.anagram.at\/app\/uploads\/2014\/06\/BlenderMovingObjectsLogicEditor-300x191.jpg 300w, https:\/\/www.anagram.at\/app\/uploads\/2014\/06\/BlenderMovingObjectsLogicEditor.jpg 705w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As i&#8217;ve received some good information through YouTube videos, let me know if anyone is interested in seeing some videos from Anagram as well.<\/p>\n<h2>I&#8217;ve added a linked object and want to move it. How can I do?<\/h2>\n<p>If you want to move linked objects, you have to make them a proxy.<\/p>\n<pre>\r\nCTRL + ALT + P\r\n<\/pre>\n<p>will do so.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes a way to &#8220;pick and move objects&#8221; in Blender Game Engine. Unfortunately a lot of published code is not working with the current version of Blender or depends on specific objects within the scene. I wrote the code to try some 3D Collision Shapes. In order to do that, i wanted to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":""},"categories":[79],"tags":[100,101,102,103],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Harald","author_link":"https:\/\/www.anagram.at\/en\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/1930"}],"collection":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/comments?post=1930"}],"version-history":[{"count":2,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/1930\/revisions"}],"predecessor-version":[{"id":2777,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/posts\/1930\/revisions\/2777"}],"wp:attachment":[{"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/media?parent=1930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/categories?post=1930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anagram.at\/en\/wp-json\/wp\/v2\/tags?post=1930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}