Making 2 objects move & rotate together in game engine


Scenario is I would like to create object A (a sensor) and connect it to object B (a body) - both are simple cubes. When sensor senses, object B rotates - this works fine.

Problem is getting object A to move correctly with object B (maintain the same relative position and orientation). Parenting A to B gets them to move together correctly - until the rotation is applied to object B. Object A doesn’t get the rotation.

Is there a better way to do this?

You can have them use
Python ,
own.worldPosition= target.worldPosition
own.worldOrientation = target.worldOrientation

But I am not understanding why you are applying the rotation in the first place.

Maybe explain the whole scenario better?

Parenting means the child object inherits all transformations (position, orientation and scale) from it’s parent adding it’s local transformation.

So I’m confused too, what you mean, with “A doesn’t get the rotation”.

Thanks for taking the time to reply.

By ‘not get the rotation’ I meant just that - as the parent rotated in game mode, the child (sensor) was following it but maintaining its rotation.

In the end I solved the use case a different, more stable way.

The use case was creating autonomous cars to move around a game world in a semi-realistic way. I was using sensors simply to get the car to turn away from obstacles.

It turned out to be better to do this with ray casting from the main parent object (the car) rather than adding separate ‘sensor’ objects. This was much simpler and more stable.