Object smoothly rotate to its parent rotation

Hello guys, I made a code to make an object, when i press a button, copy the rotation of his parent(vertex parent), the problem is that I am getting a kind of abrupt change in orientation, and what I wanted was a smooth movement. Anyone knows how to change the code?



import bge








scene = bge.logic.getCurrentScene()
cont = bge.logic.getCurrentController()
own = cont.owner
child = own.parent


own.worldOrientation = child.worldOrientation


Can you specify how you are getting an abrupt change in orientation?

Here’s an example of a vertex parented object (the squished sphere) to a plane (deformed). This orientation is smooth, and it copies the orientation of its parent (vertex parent):

Rotate.blend (524 KB)

In addition, the cube is added to the scene and immediately parented to the plane. Then, the cube assigns its parent’s orientation.

Thanks.

look into allignAxisToVect() it works like an trackto actuator and you can set the rotation speed.


def face_direction(obj, vector):
    
    track_axis = 1 # x,y,z = 0,1,2
    turn_speed = 1.0 # 0.0 - 1.0
    
    # face direction
    obj.alignAxisToVect(vector, track_axis, turn_speed)
    # head up
    obj.alignAxisToVect([0.0,0.0,1.0], 2, turn_speed)

pass the object that needs to align and the vector it needs to align to to the above function. set the speed how you want it. 1.0 is instant lower is slower.