I see that getting intersected parts with ignored list for rays is deprecated. How do I use the up to date version to get a list of all intersecting parts on a ray (ideally which will just be the length of a single part)?
If you mean searching for parts with an ignore list then just use the new :Ray function using as parameters, origin, direction, and raycastparams
check the raycast params and set the filtertype to blacklist
That + putting every intersected part into a table.
Yeah of course, let me know if it worked.
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {}
raycastParams.IgnoreWater = true
local RayCasted = workspace:Raycast(Part.Attachment0.Position, (Part.Attachment0.Position - Part.Attachment1.Position), raycastParams)
print(RayCasted)
It just seems to print nil.
It didn’t work, ^ I just wanted to let you know.
You wrote the direction wrong, try this:
(EndingPoint - StartingPoint)
So in other words, reverse
(Part.Attachment0.Position - Part.Attachment1.Position)
to
(Part.Attachment1.Position - Part.Attachment0.Position)
is what you’re saying?
Still did not work.
local RayCasted = Ray.new(Sword.Attachment0.Position, (Sword.Attachment1.Position - Sword.Attachment0.Position))
Are you sure there is a part between those two points or that the code is right?
You should use Attachment.WorldPosition, position is relative to its parent
local RayCasted = Ray.new(Sword.Attachment0.Position, (Sword.Attachment1.Position - Sword.Attachment0.Position))
print(RayCasted)
local Hit_Parts = GetAllParts(RayCasted, Sword)
local function GetAllParts(Hit, Sword)
local Parts = {Sword}
local LastPart
if Hit ~= nil then
repeat
LastPart = workspace:FindPartOnRayWithIgnoreList(Hit, Parts)
table.insert(Parts, LastPart)
until LastPart == nil
end
return Parts
end
The ray is created in a loop.
I actually do not know much about the WorldPosition properties I’ve been seeing. Could you explain it a bit more for me and how I would go about doing that?
sorry i wasn’t on pc for quite a while,
WorldPosition is basically the position in world space which is the space you’re working on when using Rays
Attachment.Position is the position relative to its parent which is your model/part or whatever you’re using. default position would be Vector3.new(0,0,0) which would be in the middle of the part/model since it’s relative to the parent.
Vector3.new(0,0,0) in world space would be in a whole different position than you are right now and that is why you are not getting any results.
let’s say you have 2 parts and they’re in both different positions and both have attachments with default positioning,
the ray would basically fire from Vector3.new(0, 0,0) to Vector3.new(0, 0, 0) in world space and would obviously find nothing
so to recap this, WorldPosition is the position of the attachment in world space which is what u want
So in other words…
I need to check for the attachment world position! That makes a lot of sense. xd