Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Creating the opposite of a Vector3 across a plane?

Asked by 5 years ago
Edited 5 years ago

I'm trying to get an effect where my characters arms point towards my mouse, but not in the normal way. I want the left arm to point to the opposite location of my right arm but along the X and Z plains only, the problem im having is that depending on my rotation the left arm wont move itself to the correct location and eventually I gave up and erased what I had wrote, now im just unsure on what to do exactly to get the effect I want. The left arm will usually end up either pointing behind me or pointing to the wrong side depending on my rotation and im not sure what to do.

This is my code,

local hit = Mouse.Hit

local direction = hit.p + (hit.lookVector * 5000)
local direction2 = -- not sure what to do here

local rootCFrame = HumanoidRootPart.CFrame
local rotationOffset = (rootCFrame - rootCFrame.p):inverse()

RightShoulder.Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.pi / 2, 0, 0)
LeftShoulder.Transform = rotationOffset * CFrame.new(Vector3.new(0,0,0), direction2) * CFrame.Angles(math.pi / 2, 0, 0)

Answer this question