Copy rotation – UPBGE / BGE
Is it possible to copy the rotation of another object in the BGE/UPBGE?
You might have noticed that constraints does not work in the game engine , so, the answer is yes, and maybe possible in several ways (“track to” actuator but might be a little bit tricky) but the most easy and accurate would be with Python.
This is possible with a simple python script:
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:
This example works in the UPBGE and the BGE
Grab the Blend file here