Hey, I’ve recently been trying to make projectiles in my game instead of hit scan. Currently, I have a module called FastCast which I heard was pretty good when used correctly, however, the projectiles seem to be extremely laggy.
For anyone curious, the server FPS has been between 56-60 the entire time, but the problem still persists.
Another note is that, whether or not the projectile is anchored or unanchored, it still lags regardless.
FastCast: API: FastCast API
Code:
--[[ CASTER FUNCTIONS ]]--
Caster.LengthChanged:Connect(function(ActiveCast, LastPoint, RayDir, Displacement, SegmentVelocity, CosmeticBulletObject)
local NewPos = LastPoint + (RayDir * Displacement)
CosmeticBulletObject.Position = NewPos
end)
Caster.RayHit:Connect(function(ActiveCast,RaycastResult,SegmentVelocity,CosmeticBulletObject)
if ActiveCast.UserData["ExplodeOnImpact"] == true then
CosmeticBulletObject:Destroy()
Explode(ActiveCast.UserData["Player"],ActiveCast.UserData["Weapon"],RaycastResult.Position)
else
CosmeticBulletObject.Anchored = false
CosmeticBulletObject.CanCollide = true
end
end)
function FireProjectile(Player,Weapon,CamCFrame)
local Offset = WeaponStats[Weapon]["Offset"]
local Behavior = ProjectileBehaviors[Weapon]
CastParams.FilterDescendantsInstances = {Filter}
local ActiveCast = Caster:Fire((CamCFrame * CFrame.new(Offset)).Position, CamCFrame.LookVector, WeaponStats[Weapon]["Velocity"], Behavior)
ActiveCast.UserData = {
["Player"] = Player,
["Weapon"] = Weapon,
["ExplodeOnImpact"] = WeaponStats[Weapon]["ExplodeOnImpact"],
}
end