Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help making my RayCast aim down at the ground instead of where you look?

Asked by
StoIid 364 Moderation Voter
8 years ago

I am trying to make this ray aim down so i can find the part that's under you but it keeps only going in the direction of the lookVector.

This is what i have so far related to the Ray.

local torso = player.Character.HumanoidRootPart
        local ray = Ray.new(torso.CFrame.p, (torso.CFrame.lookVector + CFrame.fromEulerAnglesXYZ(0,math.rad(90),0 ).p)*100)
            local part, position = game.Workspace:FindPartOnRay(ray)         
            print(part.Name)

I played around with it and tried different CFrame combos but it seems to not work and only go in the direction you're looking. I'm trying to angle it down at the ground.

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Try Changing The Angle From 90 To 270 This May Just Work By Flipping The Angles! (Be Sure To Upvote If this helped! :D) So The Code Will Look Like This:

local torso = player.Character.HumanoidRootPart
        local ray = Ray.new(torso.CFrame.p, (torso.CFrame.lookVector + CFrame.fromEulerAnglesXYZ(0,math.rad(270),0 ).p)*100)
            local part, position = game.Workspace:FindPartOnRay(ray)         
            print(part.Name)

0
didn't help. Still gets the part i'm looking at. StoIid 364 — 8y
0
Weird AlexColton 29 — 8y
0
worked, just had to switch like you said and do something a lil different. Thanks. StoIid 364 — 8y
0
NP :D AlexColton 29 — 8y
Ad

Answer this question