Rotating vector in a forloop?

Hello, Sorry if this seems kind of dumb but I figured I should ask anyway … It seems complicated in my mind.

I have a forward vector multiplied by some distance from a transform, I want to get those points that you can see on the big image below (sorry about that)

In red, you can see the forward vector, and the black dots are the vector points that I want to get, they are 5 degrees apart from the middle… like -5, +5 etc.

42463-photo+(6).png

I want to basically get some points and do a trace line on all of them at the same time almost, thats why the forloop.

Somebody could help me? I am quite new and rotations get me confused.

Well all of these points could be represented in local space and then transformed into world space for the line tracing.

So here’s some pseudo code and I’m ignoring the Z for now:

// all local
FVector PointArray = 
{
    FVector(-1, 1), // TopLeft
    FVector(0, 1), // TopMiddle
    FVector(1, 1), // TopRight
    FVector(1, 0), // MidRight etc..
    FVector(1, -1),
    FVector(0, -1),
    FVector(-1, -1),
    FVector(-1, 0)
};

FTransform CenterTransform = GetActorTransform() <or> Component.GetTransform()

for (int i = 0; i < PointArray.Num(); ++i)
{
    FVector TransformedVector = CenterTransform.TransformLocation(PointArray[i]);
    // you then use this transformed vector as the end or start point of a ray trace,
    // the other point is either GetActorLocation or GetComponentLocation
}

I actually want to do that in blueprint, would that be possible? and also I want to get something like:

transform → forward vector of transform * 100 = “myPoint”

I want to get “myPoint” 5 and -5 degrees apart in X and Y, resulting in 9 points total.

would i be using things like rotate vector on angle or something like that?

You could rotate a Vector of length 100, say a Vector(100, 0, 0), for your 9 points in local space once at the construction of the blueprint, and then transform each point during runtime (which you can do in blueprint with TransformLocation, you just have to provide either the actor transform or a component’s transform). It’s important to realize you can scale the vector(s) before transforming. I could have written my pseudocode with all those vectors using 5s instead of 1s (though obviously they’d have different lengths, but if you’re going to rotate one vector, that won’t be a problem).

I’m struggling a bit with understanding how a 5 degree rotation would give 9 points. But there is a RotateVector and you can rotate it on a certain axis. So, again, at construction you could have a Vector(100, 0, 0) that you rotate the yaw on 9 times to get your 9 different Vectors. You put these all in an array and then you ForEachLoop over that array later and TransformLocation on each point to get the end point for your ray trace. If you want to ray trace each point with eachother, you simply have a variable to store off the previous location and then ray trace between those (in your picture that ray trace would produce a square).

BTW, your reply should have been a child to my answer (“add new comment”).