If cube1 has rotation logic, how can I make cube2 imitate the rotation of cube1 without using the logic of cube 1?
This is possible with a simple python script:
import bge def main(): scene = bge.logic.getCurrentScene() cube1 = scene.objects["realCube"] cube2 = scene.objects["secondCube"] cube2.worldOrientation = cube1.worldOrientation
secondCube are the names of the actual cube objects in blender.
To attach this script to
secondCube, you can use a python controller with an always sensor. Note that the script name must end in a
.py extension for the script to be recognized as a module, and that the python controller is given a method (
.main) defined as a function inside the script:
One way is to use drivers. You can, in effect, link the properties of one object to other objects. In your example, you have the choice of driving all 3 rotation angles or just a single angle.
To add a driver, display the rotation properties of the linked-to object (cube2 in your example). An easy way to do this is press "N" in the 3D View or choose the Object Properties tab. Then right-click one of the rotation angle values. Choose "Add Drivers" (all 3 rotations) or "Add Single Driver" (only the chosen rotation). The property value will turn purple and can no longer be changed manually. You can remove the driver by right-clicking and choosing again.
Next open a Graph Editor window and press "N" to display the Properties sidebar. To the right of the window menu ('View', 'Select', 'Marker', 'Channel', 'Key'), there is a drop-down labeled "F-Curves". Change this to "Drivers".
For simplicity sake, I'll describe how to set up one driven rotation angle. If you want to drive 2 or 3 rotation angles, simple repeat the following steps:
In the upper left, click one of the angles below "Drivers". If they aren't visible, you may need to click "Drivers". Find the Drivers panel in the right-hand Properties sidebar. This panel shows the driver setup.
The first item you likely want to change is "Scripted Expression" to either "Averaged Value" or "Sum Values". Since you want to copy a single property, you will get the property you want by choosing the average or sum of that single value. (This was confusing to me at first, but it provides a lot of power and flexibility in more complex situations.)
By default, a variable has been created called "var". Choose the driving object (cube1 in your example) and then choose the property you want to copy using the "Type" drop-down menu.
You might click "Update Dependencies" if an error message appears beneath the "Remove Driver" button.
You can test out the driver by rotating cube1 and watch cube2.
Other resources on using drivers: