Creature ground -> fly problem.

Hello there, can i have some advice on how to make a creature fly from ground to air?

Let me explain the situation.

I have a creature with Inhabit type 5 on my database that starts from the ground. Then, in the core, I call GetMotionMaster()->MoveTakeoff(0, position) where position is the position with Z relocated.

Now… the creature goes in the air where i want it to be, but when I go there, and it enters combat with me, the creature will just ignore his Z position and goes to the middle of the ground (still Flying) and then start to attack me. (Half of his body is buried into the ground and it still flies).

I want to know if there are some other things to do (db or core) that I am missing.

Thank you in advance.