Vectors in UE

I’m trying to get a simple Cross product between a vector and a “world” up vector.
steps i take:
1 get vector between players
2 get mid point between players
3 get cross product of the players vector and 0,0,1
4 add normalized cross vector * length to mid point

result for step 1 & 2 looks fine if i debug, ignore the red one, blue is the vector between players, green the mid point.

but for 3 & 4, it seems incorrect, red is the up vector, pink the cross result. I expect the pink one to be perpendicular to the blue one.
image

here is the blueprint to calculate the vectors

and this is for debugging

You shouldn’t add the direction vector to the actors location, it will give a different direction when you normalize it after.

Try this if what you are after is a rotator:


CrossA

Or this for the vector:


CrossB


Hope it helps.

2 Likes

hmm strange, i did try without but still got wrong result, try it again and now it seems fine… Maybe saved instead of compiled. Still getting use to UE. also cool about the Math expressions didn’t know these :wink: still a lot to learn and discover.

2 Likes