How to draw a line (or raycast) straight up from a 2D object and rotate when the object rotates?

function FixedUpdate () {
    Debug.DrawLine (transform.position, transform.TransformDirection(transform.up));
}

The line for some reason shoots up diagonally to the right and when the object rotates the line starts to rotate more slowly than then the object and then just starts rotating the other way.

I think it is because you are applying transform.TransformDirection() to the transform.up property, which already points “up” relative to the transform you are on.

You can either do transform.TransformDirection( Vector3.up) or else just use transform.up directly.

Kurt