I am trying to cast a line forward from ai actor but the line is not straigh forward it is shooting up

I am trying to cast a line forward from the actor to detect if there is any obstacle in the way but the line is shooting up not forward

in the second img the start pin is from get actor location node

Check the Actor mesh orientation in the actor class viewport. The mesh needs to face the X axis.

If the origin point of the mesh is off, then you should add a scene component to the Actor and have it as the parent. Then adjust the rotation of the mesh.

i tried adding a sconce component but when i did that the character was invisible and the line was still tilted, i also tried changing the skeletal mesh but still the line remain tilted upword.

Your issue is that the “End” location of your LineTraceByChannel is just the forward vector multiplied by same value.

You have to add the start location to the (Forward Vector * Ray Length) result.

If, for instance, forward vector is (1, 0, 0) and ray length 1000, then your final result would be
(1000, 0, 0) which is a point relative to the pawn.
However, the End location should be in world-space, so you need to add the pawns location to the result.

Which should look somewhat like this:

Vector Start = GetActorLocation()
Vector End = Start + GetActorForwardVector() * RayLength

hey, I added the start to the result like you told me but now the rays is shooting downward not straight forward like i want it to