I am using fastcast to simulate bullets with a gun. However, the cosmetic bullets I have created do not follow the ray visualization(the black lines). I am a fastcast noob so i don’t know what I am doing
fastcast code:
local weapon = char:FindFirstChildOfClass("Tool")
local origin
if not weapon then return end
if (localplayer.Character.Head.CFrame.p - camera.CFrame.p).Magnitude < 1 then
origin = camera.Viewmodel:FindFirstChildOfClass("Tool").Model.Shoot.Position
else
origin = weapon.Model.Shoot.Position
end
local tool = char:FindFirstChildOfClass("Tool")
local itemstats = require(tool.Itemstats)
local mousecastparams = RaycastParams.new()
mousecastparams.IgnoreWater = true
mousecastparams.FilterType = Enum.RaycastFilterType.Exclude
mousecastparams.FilterDescendantsInstances = {camera.Viewmodel, localplayer.Character}
local direction = (GetMouse(itemstats.weaponstats.range, mousecastparams) - origin).Unit
local castbehavior = fastcast.newBehavior()
castbehavior.Acceleration = replicatedstorage.bulletGravity.Value
castbehavior.RaycastParams = params
castbehavior.AutoIgnoreContainer = false
castbehavior.CosmeticBulletContainer = workspace.CosmeticBulletsContainer
castbehavior.CosmeticBulletTemplate = replicatedstorage.GameItems.Bullet
caster:Fire(origin, direction, itemstats.weaponstats.velocity, castbehavior)
caster.RayHit:Connect(function(hit)
print(hit.Instance)
end)
you can see in the video how the console prints nil for hit.instance