Copying Rotation In-Game?

Game Engine, Players & Web Plug-in, Virtual Reality, support for other engines

Moderators: jesterKing, stiv

Post Reply
Unvisibleness
Posts: 0
Joined: Sat Apr 25, 2009 5:03 am
Location: Australia

Copying Rotation In-Game?

Post by Unvisibleness » Sat Apr 25, 2009 5:08 am

I was wondering how I could get one object to copy the rotation of another object in-game.

bmud
Posts: 0
Joined: Sun Feb 08, 2004 8:13 am
Location: Raleigh, NC, USA
Contact:

My favourite way

Post by bmud » Wed May 27, 2009 11:02 pm

You can go about this in two ways...

If you use this script, attach a "Message" actuator and name it "child" or "parent" respectively and make sure both are connected to the same python controller.

Code: Select all

# use the current logic brick
controller = GameLogic.getCurrentController()

act = controller.getActuator("parent")
Parent = act.getOwner()

act = controller.getActuator("child")
Child = act.getOwner()

Parent = Parent.getRotation()
Child = Child.getRotation()

xyz = [0.0, 0.0, 0.0]
xyz[0] = (Parent[0] + Child[0]*2)/3
xyz[1] = (Parent[1] + Child[1]*2)/3
xyz[2] = (Parent[2] + Child[2]*2)/3

Child.setRotation(xyz)

Post Reply