Rotate and move heat seeker towards target

I am working on a 2D game heat seeker code.

This is what I want it to do; after firing it will move around the screen couple of times, then moves towards the target.

I got the first part working.

But the second part does not seem to work properly when the target is close to the rocket when it starts the phase 2.

void FixedUpdate () 
        if (movingState == 1)
            rotationAngle += Time.fixedDeltaTime*150;
            trans.rotation = Quaternion.AngleAxis(rotationAngle * moveDirection, Vector3.forward);
            trans.position += (trans.right * Time.fixedDeltaTime * movingSpeed + new Vector3(xShift, yShift, 0));

            if (rotationAngle > 360)
                rotationAngle -= 360;

                if (rotateCount > 1)
                    movingState = 2;


        if (movingState == 2)

            _direction = (target - trans.position);
            _lookRotation = Quaternion.LookRotation(_direction);
            _lookRotation.x = 0;
            _lookRotation.y = 0;
            trans.rotation = Quaternion.Slerp(trans.rotation, _lookRotation, Time.fixedDeltaTime * 10);
            trans.position += (trans.right * Time.fixedDeltaTime * movingSpeed);

            if (Vector3.Distance(trans.position, target) < 0.1f)

Can anyone provide some help on this?

i don’t understand the situation you gave

but maybe this link will help you:

First off, this should be in Update I would imagine. Secondly you are modifying the components of a quaternion which are not the rotation angles. Either fiddle with the eulerAngles property of the rotation returned from LookRotation - which is what you think you are doing - or adjust the trans.position so that it on the same plane as the target.

See this for a discussion of Quaternions: - unitygems Resources and Information.