Raycast just does not work, I dont know what to do now,
cf is an actual cframe not from a part but a variable.
please help
Ray.new( (cf + cf.LookVector * 3).p , cf.RightVector * 40)
Raycast just does not work, I dont know what to do now,
cf is an actual cframe not from a part but a variable.
please help
Ray.new( (cf + cf.LookVector * 3).p , cf.RightVector * 40)
But i need to ignore certain items, can it ignore?
Ray.new still works but is technically deprecated
If you want to use workspace:Raycast there’s many tutorials on how to do it, it can whitelist and blacklist parts easily if you know how
If you want to still use ray.new you’ll have to show your entire code relating to the raycast like where you’re actually casting it and setting up the settings for the raycast
I’m sure we’d all be glad to help you with either of these things if you need it
local studs = 1
for i = 100, 1, -1 do
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {victim.Parent, script.Parent}
raycastParams.IgnoreWater = true
local part = workspace.Part
local raycastResult = workspace:Raycast((cf + cf.lookVector * walls.Size.Z/1.5 + cf.RightVector * studs).p, cf.RightVector * studs + cf.lookVector * walls.Size.Z/1.5 , raycastParams)
if raycastResult then
print("OMG")
end
local raycast = Ray.new((cf + cf.lookVector * walls.Size.Z/1.5 + cf.RightVector * studs).p, cf.RightVector * studs + cf.lookVector * -walls.Size.Z/1.5 )
local barr,pos,nor = workspace:FindPartOnRayWithIgnoreList(raycast, {victim.Parent, script.Parent})
if not barr and not raycastResult then
amountmisses = amountmisses + 1
placemissed = (cf + cf.lookVector * walls.Size.Z/1.5 + cf.RightVector * (studs + 8)).p
break
end
if barr then
print("BARRR")
end
studs = studs + 1
end
ok so i do admit im doing something complex hopefully it is understandable but it doesnt seem to work
Nevermind it worked because of Paramsl, just took a while for it to work
ill have to take it back, still doesnt work
Is this a roblox bug because there seems to be nothing wrong with the code
What issue specifically are you having?
the raycast would not work, imagine this, u want the red part position to detect the white while and the direction is the blue parts position, but instead u dont say part.Position and instead the position is a variable
local cframe = part.CFrame.p
then use that in the ray, for me it doesnt seem to work and it’s irritating, i’ve been getting alot of different bugs this week and its demotivating me right now.
This is the code i had
local raycast2 = Ray.new((cf + cf.lookVector * walls.Size.Z/1.5 ).p, (cf +
cf.RightVector * -studs + cf.lookVector * walls.Size.Z/1.5 ).p)
local barr2,pos2,nor2 = workspace:FindPartOnRayWithIgnoreList(raycast2,
{victim.Parent, script.Parent})
local raycast = Ray.new( (cf + cf.lookVector * walls.Size.Z/1.5 + cf.RightVector * -studs).p, cf.RightVector * -studs + cf.lookVector * -walls.Size.Z/1.5)
local barr,pos,nor = workspace:FindPartOnRayWithIgnoreList(raycast, {victim.Parent, script.Parent})
if not barr and not barr2 then
amountmisses2 = amountmisses2 + 1
placemissed2 = (cf + cf.lookVector * walls.Size.Z/1.5 + cf.RightVector * -(studs + 8)).p
break
end
studs is just a number that increases by 1 every 0.03 seconds and its in an i = 500, 1, -1 loop
and it just does not work
if raycast2 detects something then raycast does not work
Do you want to cast to the blue part?
that was just an example my code is alot more complex that that, i used a ray to detect a block, got its normal and the side it hit. In this case the ray hit the back of the part
So now we have the part, the normal and the side
we will make a cframe out of the parts position and ray’s normal
Cframe.new(parts.Position, parts.Position + n)
get the size of the axis it hit which is Z in this case
so u can get the front of the part
Cframe.new(parts.Position, parts.Position + n) + Cframe.new(parts.Position, parts.Position + n).lookVector * (part.Size.Z/1.5)
now we make another cframe but this time making it to the right
Cframe.new(parts.Position, parts.Position + n) + Cframe.new(parts.Position, parts.Position + n).lookVector * (part.Size.Z/1.5) + Cframe.new(parts.Position, parts.Position + n).RightVector * side
in this case side is 11 which means 11 studs to the right of that cframe
after that we change both to a position
(Cframe.new(parts.Position, parts.Position + n) + Cframe.new(parts.Position, parts.Position + n).lookVector * (part.Size.Z/1.5)).p
(Cframe.new(parts.Position, parts.Position + n) + Cframe.new(parts.Position, parts.Position + n).lookVector * (part.Size.Z/1.5) + Cframe.new(parts.Position, parts.Position + n).RightVector * side)
and we make a ray with it
but all that work that was done is just pointless. the ray just does not work. hope u can see why im irritated right now it is supposed to work and just decided not to.
if u want to know what my code is, its a path finder and i dont want to use pathfinding service instead i have to use rays