• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Welcome to the world of Anagram Engineering
  • Who we are
  • Leistungen
    • Web Development
    • Embedded Systems
  • References
    • Customers
    • Webdesign & Webapps
    • Mobile Apps
    • Embedded Systems
    • Cloud Apps
  • News

Search

Anagram Engineering

Webdesign und Softwarelösungen aus Vorarlberg. Ihr Partner für innovative Lösungen rund ums Internet. Full Service Agentur.

June 24, 2014 by Harald

Move Objects in Blender Game Engine

This article describes a way to “pick and move objects” 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 have the objects movable to see how they interact with other objects.

Let me know if you see any improvements and leave a comment if it’s useful for you.

The code does the following:

  • pick an object with left or right mouse click
  • move it as long as the mouse is clicked, release it otherwise
  • move on x/y plane with LMB, move on y/z plane with RMB

Currently i’m fine with moving them with 3DOF, so i can move them in X,Y and Z direction.

I have written this little script, which is triggered by MouseOverAny, Left Mouse Button Click and Right Mouse Button Click.

I’ve assigned the sensors to the camera, which i thought is probably the only object that will stay within the scene.

import bge

cont = bge.logic.getCurrentController()
LMB = cont.sensors["LMB"]
RMB = cont.sensors["RMB"]
if LMB.positive | RMB.positive:    
    mouseOver = cont.sensors["MouseOver"]
    obj = mouseOver.hitObject
    mouseX = mouseOver.hitPosition[0]
    mouseY = mouseOver.hitPosition[1]
    mouseZ = mouseOver.hitPosition[2]

    if LMB.positive: 
        obj.position[0] = mouseX
        obj.position[1] = mouseY
    if RMB.positive:
        obj.position[1] = mouseY
        obj.position[2] = mouseZ

The assignments can be seen here:

BlenderMovingObjectsLogicEditor

As i’ve received some good information through YouTube videos, let me know if anyone is interested in seeing some videos from Anagram as well.

I’ve added a linked object and want to move it. How can I do?

If you want to move linked objects, you have to make them a proxy.

CTRL + ALT + P

will do so.

Filed Under: News Tagged With: 3D, blender, game engine, python

About Harald Entner

Since january 2013 Harald is CEO of Anagram Engineering.

After he has finished his study in computer science at the Technical Universicty of Vienna he worked in Vienna, Munich and Dornbirn as software engineer, software architect and system developer.

Today he enjoys travelling, learning new languages and frameworks, systems, environments and tries to educate hilmself within these domains.

Primary Sidebar

Recent Posts

  • Zumtobel PROset App | Rebranding February 3, 2021
  • Speed matters July 2, 2019
  • Vienna calling June 18, 2019
  • Resclite Pro April 12, 2019
  • Zumtobel PROset App April 10, 2019

Legal

  • AGB
  • Impressum

Footer

Contact US

Stiegstrasse 24
6830 Rankweil

+43 650 925 62 64

About US

Anagram Engineering develops software for Web, Mobile, Tablet and embedded devices.

Learn More

© 2025 · Anagram Engineering

  • terms & conditions
  • impress
  • customers
  • References
  • who we are
Manage Cookie Consent
Wir benützen Cookies um unsere Website und unsere Services zu optimieren.
Funktional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistik
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
Einstellungen
{title} {title} {title}
  • Deutsch
  • English