Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I add a vector based on rotation?

I'm having a part follow the mouse. But when the player isn't facing a certain direction, mouse movements don't coordinate with where the part moves.

I tried using lookVectors as well but don't have a good understanding of using them.

local function Panned(input, processed)
	if not processed and input.UserInputType == Enum.UserInputType.MouseMovement then
	 delta = input.Delta
	panDeltaMouse = -delta
	move_vector =focus.Position-Vector3.new(delta.X,0,delta.Y)*speed -- need help here
	end
end

1 answer

You can use the .Move to detect mouse movement and set the part's position as Mouse.Hit.p (a vector3 position)

local Mouse = game.Players.LocalPlayer:GetMouse()
local Part = workspace.Part

Mouse.Move:connect(function()
	Part.Position  = Mouse.Hit.p
end)

1 comment

0

Has to use delta as is. I'm making a draggable camera. Everything works except for when orientation is off.

This discussion is preserved as it was. New answers, comments, and votes are closed.