The only thing that jumps off the page when I read this is that the rotation is far too complicated.
2D rotation is much simpler than 3D since it can be represented by a single number, an angle. If, say, the child has a rotation of 20 and the parent 50 then the child vector can be rotated by 30 ( = 50 - 20 ) to give it the parent's rotation.
In the notation of the example code the child movement vector can be rotated just once.
The angle is ( parent_global_rot - child_global_rot ).
2D rotation is much simpler than 3D since it can be represented by a single number, an angle. If, say, the child has a rotation of 20 and the parent 50 then the child vector can be rotated by 30 ( = 50 - 20 ) to give it the parent's rotation.
In the notation of the example code the child movement vector can be rotated just once.
The angle is ( parent_global_rot - child_global_rot ).