Vector3:Cross problem

im new to learning cross product and dot product i do some code and is was do some wried action


local part = workspace.Part
local part1 = workspace.Part1
function CreatePart(Position,lookat)
	local lookvector = (Position- lookat).Unit
	local UpVector = Vector3.new(0,1,0)
	local Rightvector = lookvector:Cross(UpVector)
	local LeftVector = lookvector:Cross(Rightvector)
	local upvector2 = Rightvector:Cross(LeftVector)

	return CFrame.fromMatrix(lookat, Rightvector, upvector2)

end 

part1.CFrame = CreatePart(workspace.Part.Position,workspace.Part1.Position)

before:

After:

1 Like

The vector labels are a bit confusing. What is LeftVector supposed to be? Based on its definition it is orthogonal to RightVector which doesn’t make sense.

It appears you are trying to get one part to look at another, any reason you aren’t using CFrame.lookAt(pos, lookAt, upVector) for this instead? That allows you to specify an upVector as the third argument also.

2 Likes