hello! there’s a silly little math problem that’s been bullying me for a while now. my goal is to rotate a vector 90° in the direction of another vector.
the blue vector is the direction and the green one is the one i want to rotate by 90 degrees on that axis. the red vector represents the desired result.
i’m willing 2 bet the answer is something rlly simple, but it looks im not smart enough 4 that yet
thank u 4 ur time
hang on, i managed to come up with a solution! it’s far from elegant, and it isn’t perfectly precise, but it’s simple and works pretty well!
here’s what it looks like:
local up = script.Parent.green
local direction = script.Parent.blue
local result = script.Parent.red
local zero = Vector3.zero
local upVector = up.CFrame.UpVector
local lookVector = direction.CFrame.UpVector
local angle = lookVector:Dot(upVector)
local resultVector = (CFrame.lookAt(zero, zero + lookVector) * CFrame.Angles(-angle, 0, 0)).LookVector
if anyone has a better solution, i’d still love to hear it!