How would i make a model a specific angle?

so i have a blow gun that shoots a dart towards a target but when i spawn the dart, it’s orientation isnt completely straight; which is how i want it to be.

i want the dart to be 90 degrees; parallel to the baseplate if you will. how would you do that? i appreciate any help :slight_smile:

this is what i mean:

local function makeDart90Degrees()

end

local function sendDartToBlowgun()
	local handleCFrame = blowgun:GetPivot()
	local endPart = blowgun.endpart
	local offsetZ = (blowgun.Handle.Size.Z / 2) + (endPart.Size.Z) + (blowgun.Handle.Size.Z / 4.5)
	local blowgunEndCFrame = handleCFrame * CFrame.new(0,0,-offsetZ)
	local mouseScreenPosition = game:GetService("UserInputService"):GetMouseLocation()
	local camera = workspace.CurrentCamera
	local rotation = CFrame.Angles(math.rad(90), 0, 0)
	local mouseRay = camera:ViewportPointToRay(mouseScreenPosition.X, mouseScreenPosition.Y, 0)

	local rayEndPoint = mouseRay.Origin + mouseRay.Direction * RAY_DISTANCE

	local lookat = CFrame.lookAt(blowgunEndCFrame.Position, rayEndPoint)
	local finalCFrame = lookat * CFrame.new(0,0,0) * rotation
	return finalCFrame, rayEndPoint, blowgunEndCFrame

end

You can lock the Y axis of CFrame.lookAt so the two points are on XZ plane parallel to the baseplate, use the same rayEndPoint XZ coordinates but make the Y coordinate the same as the origin blowgunEndCFrame.Position.Y .

Below uses CFrame.new() which does the same thing as CFrame.lookAt unless you were the include the third parameter of CFrame.lookAt which is not necessary for this scenario.

1 Like

thanks a million for your help man; i was about to do 200 calculations in order to get this to work. you’re a living legend. :slight_smile:

(just gonna keep this here just in case i need it in the future)

local function sendDartToBlowgun()
	local handleCFrame = blowgun:GetPivot()
	local endPart = blowgun.endpart
	local offsetZ = (blowgun.Handle.Size.Z / 2) + (endPart.Size.Z) + (blowgun.Handle.Size.Z / 4.5)
	local blowgunEndCFrame = handleCFrame * CFrame.new(0,0,-offsetZ)
	local mouseScreenPosition = game:GetService("UserInputService"):GetMouseLocation()
	local camera = workspace.CurrentCamera
	local rotation = CFrame.Angles(math.rad(90), 0, 0)
	local mouseRay = camera:ViewportPointToRay(mouseScreenPosition.X, mouseScreenPosition.Y, 0)

	local rayEndPoint = mouseRay.Origin + mouseRay.Direction * RAY_DISTANCE
	local rayEndPointXZ = Vector3.new(rayEndPoint.X, blowgunEndCFrame.Position.Y, rayEndPoint.Z)

	local lookat = CFrame.lookAt(blowgunEndCFrame.Position, rayEndPointXZ)
	local finalCFrame = lookat * CFrame.new(0,0,0) * rotation
	return finalCFrame, rayEndPointXZ, blowgunEndCFrame
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.