FastCast it's not casting bullet ray properly

I’m making a gun system with FastCast but the bullet direction seems to be pointing to the FirePoint look vector instead of using the given direction that points to the center of the Camera, I really find this weird as the example gun of the module is not limited to the fire point look vector.

I use this to calculate to communicate with server and it haves the direction calculation

gunEvent:FireServer(
    "Shot",
    {
        Direction = CFrame.lookAt(Vector3.new(), workspace.CurrentCamera.CFrame.LookVector).LookVector,
        FirePoint = Viewmodel.Core.FirePoint.Position
    }
)

This it’s the server response to this event (not the full code but it shows the FastCast things)

local directionRay = params.Direction
local firePoint = params.FirePoint

gunCaster:Fire(
    firePoint,
    directionRay,
    gunSettings.Speed,
    gunCasterBehavior
)

gunReplicate:FireAllClients(
    'VisualizeBullet', 
    gun, 
    firePoint, 
    directionRay,
    gunSettings.ProjectileType,
    player
)

These are the behavior params of the caster

local gunCaster = fastCast.new()

local gunCasterBehavior = fastCast.newBehavior()
local raycastParams = RaycastParams.new()

raycastParams.FilterDescendantsInstances = {character, gun}

gunCasterBehavior.Acceleration = Vector3.new(0, -10, 0)
gunCasterBehavior.AutoIgnoreContainer = false
gunCasterBehavior.MaxDistance = gunSettings.ShotDistance

And this is the LocalScript that visualizes the bullet (check the server response to know the params on this call)

local gunCasterBehavior = fastCast.newBehavior()
local casterParams = RaycastParams.new()

casterParams.FilterDescendantsInstances = {originalGun, originalGun.Parent}

gunCasterBehavior.Acceleration = Vector3.new(0, -10, 0)
gunCasterBehavior.AutoIgnoreContainer = false
gunCasterBehavior.MaxDistance = gunSettings.ShotDistance
gunCasterBehavior.CosmeticBulletTemplate = script:WaitForChild("Projectile")
gunCasterBehavior.CosmeticBulletContainer = workspace.Terrain

if player ~= params[5] then
    gunCaster:Fire(
        originalGun.Core.FirePoint.Position,
        fireDirection,
        gunSettings.Speed,
        gunCasterBehavior
    )
else
    print('VisualEffects Script', fireDirection)
    
    gunCaster:Fire(
        firePoint,
        fireDirection,
        gunSettings.Speed,
        gunCasterBehavior
    )
end

This is what I got (the things on the output are the directions)

And this is what I expected (my code it’s not based on this tutorial, just using the video as an example

I noticed that it’s a problem on my calculations but I don’t know where, I’m using the Camera LookVector so it should point at the center

The first video looks like the bullet is offset based on where the gun is (like tarkov if you have played that) while the video below shows the bullet coming out of the characters head (like COD or any other FPS).
image
You could probably use the mouse position (mouse.Hit.Position) if you want something like the video you showed.
Edit: your LookVector gets the lookvector of the camera so the direction is always where you are facing. The issue is that your origin is not where your direction is coming from causing the shots to get offset when you shoot. If you shoot when aiming down sights it looks like it’s fine but that’s because its in the center of your screen. This video explains the mouse.hit.position better than I can type.

2 Likes