Well, that doesnt work that way as _avion flyInHeight (_altura-_diferencial); will work only for AI and only if you add a move, doMove or commandMove command just after this. So each flyInHeight needs to be followed by some form of move command to activate it (you may even try to order it to move to its current position too). The AI will tend also to ignore flying heights if they are engaging some enemy. So, if you want to create something more standard, valid for AI but also for human controlled planes, you may simply play with setVelocity command to apply some positive Z when the altitude goes below the indicated one to compensate it. That Z may start with current Z (velocity vector select 2) and then you "slowly" increase it until you get a climbing attitude, you may keep applying this velocity override until the plane crosses the alt limit going up (and only if canMove returns true, else it is natural that the plane goes down and down til crash).