I’m having an issue with my RayCasting Projectiles -
It seems that depending on the Speed of the Projectile - It passes straight through objects without detecting them.
The wall you see in the video provided is loaded ClientSide - This is because I need my System to recognise when it’s hit a ‘Local’ Part (( For asthetic reasons && to prevent it travelling through ‘Local’ Parts. )) as the Projectiles generation and movement is handled by the Server.
The first few rounds are with the Speed set to 1. The others following are between 8 - 16 - Roughly where I need it to be.
ServerScript:
for i = 1, math.huge do
if not Laser or i == 100 then break end
wait()
local raycastResult = workspace:Raycast(Laser.Position, Laser.CFrame.LookVector * Speed, raycastParams)
if not raycastResult then
SpeedInc.Value, CFrameInc.Value = Speed, Laser.CFrame
Laser.CFrame = Laser.CFrame + Laser.CFrame.LookVector * Speed
else
Laser:Destroy()
Create_HitPart(LaserID, raycastResult.Position, nil)
break
end
end
LocalScript:
Character.ChildAdded:Connect(function(Child)
if Child.Name == "Laser" then
local LaserID = Child:WaitForChild("LaserID").Value
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {Player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycastResult = workspace:Raycast(Child.CFrame.p, Child.CFrame.LookVector * Child:WaitForChild("SpeedInc").Value, raycastParams)
if raycastResult then
print("Yes")
end
Child:WaitForChild("CFrameInc").Changed:Connect(function()
raycastResult = workspace:Raycast(Child.CFrame.p, Child.CFrame.LookVector * Child:WaitForChild("SpeedInc").Value, raycastParams)
if not raycastResult then
else
Child:Destroy() print("Hit")
FireServer(RemoteEvent, "onHit", nil, {LaserID = LaserID, HitPos = raycastResult.Position, Laser = Child})
end
end)
end
end)