BGE Copy object rotaion

Hi, I’ve been searching everywhere to find how to make a script that copies the rotation of one object, and applies it to another.

More accurately, location and rotation.

I can only find scripts that don’t work in 2.6

My goal is to have an object1 detect a property, if that property is true, then it will copy the rotation/location from object2 (which holds that property)


object1.worldOrientation = object2.worldOrientation # ?

Thanks, could you show me how to put that into a script (yes, I’m that noobish)

What values do I have to define in order to use that script?

Put this script the object you want to copy the other object’s rotation. Make sure you replace ‘TargetName’ with the name of the object you want to copy the rotation from.

import bge

scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()

# objects
own = cont.owner
target = scene.objects['TargetName']

# copy rotation
own.worldOrientation = target.worldOrientation

Yes, Thank you Mobious.

I see what I was missing before, I had the “scene” and “cont” part wrong earlier.