How do I make a ray go 10 studs to the left from a part?

All I want is to know how to set the ray directions to 10 studs to the left from a part?

I did this but it’s doesn’t work :

local rayStart = currentLedge.Position
local rayEnd = Vector3.new(-10,0,0)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = blacklist	
table.insert(blacklist, currentLedge)

local ray = workspace:Raycast(rayStart, rayEnd, raycastParams)

Use the parts rightVector, you were using worldspace not object space

When you create a new Vector3 it is in WorldSpace, but when we access the parts CFrame it gives us the RightVector in the objects space, which means its relative to the part not the world

@SayHelloToLazar

local rayStart = currentLedge.Position
local rayEnd = Vector3.new(-10,0,0)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = blacklist	
table.insert(blacklist, currentLedge)

local ray = workspace:Raycast(rayStart, rayStart.CFrame.RightVector * -10, raycastParams)
1 Like

take the negative of the rightvector (which is towards the left in respect to the part in question) then multiply by 10

local LeftVector = (currentLedge.CFrame.RightVector)*-1

local rayEnd = Vector3.new(LeftVector*10,0,0)
1 Like

Oh I see I didn’t know about those, thank you.
But isn’t there a leftVector?

1 Like

There is only a LookVector (Front Face) RightVector, and an UpVector. To get the Back, Left, and Down vectors you just need the opposite of the Look/Right/UpVectors, which would be the negative.

Front = LookVector
Back = -LookVector
Right = RightVector
Left = -RightVector
Top = UpVector
Bottom = -UpVector

1 Like

Oh ok it’s more clear thanks! I was a bit lost.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.