So basically I’m trying to make a car just floating and I’m pretty sure I can achieve that using Raycasting but I don’t know here to start. Would anyone like to explain the steps?
1 Like
Raycasting is like shooting an invisible beam from one point in a certain direction to see if it hits something. In Roblox, it’s often used to check if there’s anything below an object, like the ground beneath a floating car. To achieve a part floating using raycasting, you’d attach a script to the part and use raycasting within the script to detect if there’s anything underneath the part.
-- Define the part
local part = script.Parent
while true do
-- Cast a ray downward from the part's position
local raycastResult = workspace:Raycast(part.Position, Vector3.new(0, -1, 0))
if raycastResult then
part.Position = raycastResult.Position + Vector3.new(0, 1, 0)
end
wait(0.1)
end
2 Likes
I would also greatly recommend you learn raycasting from Roblox documentation as it would give you a brief overview of how it works.
Raycasting | Documentation - Roblox Creator Hub
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.