(Perhaps this module suits you better, mine is poorly tested and lacks a lot of features, it was made in a matter of minutes and just thought would be cool to share, didn’t know a not so bad number of people were going to use it. So yeah!)
With the help of this module, you can draw Vector3 and CFrame values, by literally visualizing them as parts. This can be very helpful for debugging, and even trying to understand some stuff concerning these two. Vectors are visualized as lines, CFrames have their position visualized as a line, but also displays the three rotational vectors (lookVector (-Z) is the green one, upVector (+Y) is the blue one, rightVector (+X) is the red one). You can acquire the module here, the source code is here.
Visualize(vector, origin, color, thickness, transparency)
Draws vector
starting from origin
. The default value for origin is Vector3.new(0, 0, 0)
. Optional color
, thickness
and transparency
arguments exist. The function also returns the created part. The created part is named “Vector”, parented to workaspace, and has its Locked
property set to true.
local visualizer = require(game:GetService("ServerScriptService").VectorVisualizer)
local a, b = Vector3.new(5, 8, 6), Vector3.new(6, 2, 3)
visualizer.Visualize(a)
visualizer.Visualize(b)
visualizer.Visualize(a-b, a)
VisualizeCF(cframe)
Draws cframe
. Draws its cframe.Position
, its cframe.lookVector
as the green vector, its cframe.upVector
as the blue vector, its cframe.rightVector
as the red vector. It’s fun to see how the last three vectors are affected by a rotated CFrame. All these are named accordingly and put inside a model called “CFrame”.
local visualizer = require(game:GetService("ServerScriptService").VectorVisualizer)
local a, b = CFrame.new(5, 8, 6), CFrame.new(6, 2, 3) * CFrame.Angles(math.pi, 0, math.pi/3)
visualizer.VisualizeCF(a)
visualizer.VisualizeCF(b)
visualizer.VisualizeCF(a*b)
VisualizeRay(origin, direction, params)
Draws a ray starting from origin
towards origin+direction
with params
as RaycastParams
.
ShowOrigin()
Simply displays the world’s origin, showing the +X, +Z, and +Y.
ClearAll()
Clears all CFrames and Vectors drawn.