I’m having problems where shooting into the ground causes unwanted raycasts, and I’m unsure why this is?? I am using FastCast too
Here is the client side code
-- Raycast from the mouse to get position
local Mouse = UserInputService:GetMouseLocation() or Player:GetMouse()
local UnitRay = Camera:ScreenPointToRay(Mouse.X, Mouse.Y)
local MouseRaycast = workspace:Raycast(
UnitRay.Origin,
UnitRay.Direction * 1000,
CastParams
)
if not MouseRaycast then return end
local MousePosition = MouseRaycast.Position
local FirePoint = Weapon.FirePoint.WorldPosition
Bullet.Fire(
Player, -- Player who fired
Character.Weapon, -- Weapon model
true, -- Fired
MousePosition, -- To
FirePoint -- From
)
and then Bullet.Fire is
-- Set up cast behavior
local CastBehavior = FastCast.newBehavior()
CastBehavior.RaycastParams = CastParams
CastBehavior.Acceleration = Vector3.new(0, -GRAVITY, 0)
CastBehavior.CosmeticBulletContainer = Bullets
CastBehavior.CosmeticBulletProvider = BulletCache
-- Projectile math
local Origin = firePoint
local Direction = (mousePosition - Origin).Unit
local ActiveCast = Caster:Fire(Origin, Direction, SPEED, CastBehavior) -- Fire shot
I’ve removed a lot of the unnecessary stuff. When firing normally, it works as expected. It’s only when you aim the gun into the ground, the bullets go flying off in all sorts of random directions.