I’m making a wall hopping system in my game, and I’m not that experienced with ray cast. I’m trying to figure out how to shoot a ray directly forward from the humanoids root part, should I use CFrame.LookVector?
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local root = char.PrimaryPart
local origion = root.Position
local direction = origion.Unit * Vector3.new(2, 2, 5)
local part = Instance.new("Part", workspace)
part.Anchored = true
part.Position = origion
part.Size = direction
part.CanCollide = false
while task.wait() do
origion = root.Position
part.Position = origion
part.Size = direction
local forwardRay = workspace:Raycast(origion, direction)
part.Position = origion
part.Size = direction
if forwardRay then
print(forwardRay.Instance)
end
end
I suggest instead of while task.wait() do, you use RunService, it runs every frame.
Plus HumanoidRootPart.CFrame.LookVector would work in fact, you’re correct there!