How would you cast a ray above and on the right of a character no matter where the character is facing?
Just set the direction to the vector you want (?) For the right ray there’s a special case, you will need to use the HumanoidRootPart’s RightVector.
local Character = script.Parent
local HRP = Character:WaitForChild("HumanoidRootPart")
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Blacklist
Params.FilterDescendantsInstances = {Character}
local function UpRay(Range)
local Result = workspace:Raycast(HRP.Position, Vector3.new(0, 1, 0) * Range, Params)
if Result then
return Result
end
end
local function RightRay(Range)
local Result = workspace:Raycast(HRP.Position, HRP.CFrame.RightVector * Range, Params)
if Result then
return Result
end
end
If I wanted to cast the ray forward as well, would I add the lookVector of the hrp?
Exactly! You could also use UpVector to cast it upwards.
1 Like