I’m making a simple gun system using FastCastRedux, I was wondering if there is any way to make it so that the bullet is the size of the whole cast like shown in this image:
(Basically, the bullet doesn’t travel at any speed, it is just a part with a length of the full raycast.)
Here is my code so far. I’m not sure how to implement this.
local function fireBullet(player: Player, mousePosition: Vector3)
local origin = firePoint.WorldPosition
local vectorDirection = (mousePosition - origin).Unit
caster:Fire(origin, vectorDirection, Configuration.bulletSpeed, castBehavior)
end
local function onLengthChanged(cast: any, lastPoint: Vector3, rayDir: Vector3, rayDisplacement: number, segmentVelocity: Vector3, cosmeticBulletObject: Instance?)
if cosmeticBulletObject then
local bulletLength = cosmeticBulletObject.Size.Z/2
local bulletOffset = CFrame.new(0, 0, -(rayDisplacement - bulletLength))
cosmeticBulletObject.CFrame = CFrame.lookAt(lastPoint, lastPoint + rayDir):ToWorldSpace(bulletOffset)
end
end
caster.LengthChanged:Connect(onLengthChanged)
events.Fire.OnServerEvent:Connect(fireBullet)