-
What do you want to achieve?
R= I want to get the cylinder extactly under the character with the raycast. -
What is the issue? Include screenshots / videos if possible!
R = The cylinder it’s not going in the correct position and just keeps going above the character, and giving 0,-8,0 as result no matter what i edit.
-
What solutions have you tried so far?
R = messing up with positions, changing characters and etc and haven’t found any solution.
Here is the code that i used with a normal character, giving the same results as the screenshot.
local Character = script.Parent
local root = Character:FindFirstChild("HumanoidRootPart")
local function SendRayCast(Character, RootPart)
local RayOrigin = RootPart.Position
local RayDirection = Vector3.new(0, -100, 0)
local RayParams = RaycastParams.new()
RayParams.FilterType = Enum.RaycastFilterType.Exclude
RayParams.FilterDescendantsInstances = {
Character,
--PlayerCharacter
}
local Result = workspace:Raycast(RayOrigin, RayDirection, RayParams)
if Result then
local ResultInstance = Result.Instance
print(ResultInstance.Position)
return ResultInstance
else
return nil
end
end
local function SendDestRayCast(Character, RootPart)
local RayCastResult = SendRayCast(Character, RootPart)
if RayCastResult ~= nil then
--print(RayCastResult.Position)
print(RayCastResult.Name)
print(RayCastResult.Parent)
return RayCastResult.Position
end
end
while task.wait(1) do
local Pool = Instance.new("Part")
Pool.Shape = Enum.PartType.Cylinder
Pool.CanCollide = false
Pool.Anchored = true
Pool.Parent = workspace
Pool.Size = Vector3.new(0.15, 10.359, 10.241)
Pool.Rotation = Vector3.new(0,90,90)
local Result = SendDestRayCast(Character, root)
if Result ~= nil then
Pool.Position = root.Position - Vector3.new(0, Result.Y, 0)
end
end
I hope you can help me with this problem!