For in game alignment of objects, files at bottom of page
Using force and torque -> LockStepPhysics
import bge
from mathutils import Vector
cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()
target= scene.objects['target']
Pos=own.worldPosition.copy()
distance = own.getDistanceTo(target)
vec = own.getVectTo(target)[1]
X1=own['X1']
force = vec * X1*distance
m1 = own.worldOrientation.copy()
m2 = target.worldOrientation
dif = Vector((m2 * m1.inverted()).to_euler())
x = dif.magnitude
if x > 1:
x=1
force1 = own['Force']*own.mass
own.applyTorque(dif * force1*x, 0)
own.setLinearVelocity((0,0,0),0)
own.applyForce(force/distance, 0)
own.setAngularVelocity((0,0,0),0)
Using worldPosition+ alignAxistoVect() -> LockStep
```
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
sens = cont.sensors['Named']
scene=bge.logic.getCurrentScene()
target=scene.objects['target']
TargetRot=scene.objects['Empty']
if sens.positive:
Pos=own.worldPosition
TPos=target.worldPosition
if Pos.x<TPos.x: Pos.x=Pos.x+.05
if Pos.x>TPos.x: Pos.x=Pos.x-.05
if Pos.y<TPos.y: Pos.y=Pos.y+.05
if Pos.y>TPos.y: Pos.y=Pos.y-.05
X =own.getVectTo(TargetRot.worldPosition)
own.alignAxisToVect(X[1],1,.5)
main()
### Attachments
<a class='attachment' href='/uploads/default/original/4X/8/a/b/8ab3f2335127eca0eb2a741551084f497eb4b63c.blend'>LockStepPhysics.blend</a> (462 KB)<a class='attachment' href='/uploads/default/original/4X/6/2/f/62f19df37cc858797e1a1d8600c64620db0a7e5f.blend'>LockStep.blend</a> (458 KB)