I am wanting to know how to raycast from a point, which would be the camera position, onto a grid that is facing the player. I’m able to achieve part of this until I start looking towards the z axis.
One source I did find that was helpful was this, as stated before this also comes close to what I want but just make it rotate to the lookvector of the player. Thanks you.
-- Your existing variables and setup code
-- Loop for raycasting
for _, Lidar_Box_Range_Lidar_Box_Range do
-- Calculate the direction of the raycast
local direction = (Lidar_Range * CFrame.lookVector * Vector3.new(1, 1, 1)) -- Ensure the z value is included correctly
-- Perform the raycast
local ray_object = workspace:Raycast(Camera.CFrame.Position, direction, raycastParams)
-- Check if the raycast hit an object
if ray_object then
-- Check if the hit object is a 'BasePart' and named 'Lidar_particle'
if ray_object.Instance:IsA("BasePart") and ray_object.Instance.Name == "Lidar_particle" then
-- Set the position of the 'hit' part to the raycast hit position
script.Parent.handle.hit.WorldPosition = ray_object.Position
end
end
end