I would like to orient a brick to match the direction a ray from a mouse is facing. The screenshot below might help show what I am looking to do:
However, in practice I’ve seen results like this:
I’ve tried these snippets so far:
Mouse.Move:Connect(function()
local MouseEnd = Mouse.Origin + Mouse.UnitRay.Direction
local newRay = Ray.new(AddedVehicle.VehicleSeat.Position, MouseEnd.Position)
ControlPart.Orientation = Vector3.new(newRay.Direction.Y, newRay.Direction.X, ControlPart.Orientation.Z)
end)
Mouse.Move:Connect(function()
local MouseEnd = Camera:ScreenPointToRay(Mouse.X, Mouse.Y)
local newRay = Ray.new(AddedVehicle.VehicleSeat.Position, (MouseEnd.Origin + MouseEnd.Direction))
ControlPart.Orientation = Vector3.new(newRay.Direction.Y, newRay.Direction.X, ControlPart.Orientation.Z)
end)
I’ve tried a wide variety of things, each one not seeming to work. Effectively I’m just trying to make a plane that is controlled by the mouse. I at least believe there is a UnitRay involved for the mouse, but beyond that nothing seems to work.
Any help would be greatly appreciated!