Making a combat game with ranged weapons? FastCast may be the module for you!

make a model, set the models primary part to your part, weld other parts to the primary part, use the primary part as the projectile.

1 Like

Hey, I was wondering if FastCast was still the default and best choice for raycasting and if it still receives updates. Thanks beforehand.

1 Like

I have an problem!

In my code i use the ActiveCasts UserData in which i store the player. I fire the Caster trough an Event from the Players Local and because the Casting happens on the client the UserData will change upon the firing from ANOTHER Player, which causes problems as if i shoot someone and while my bullet flies someone else shoots and MY bullet hits, it will count as his.

Heres my code from the Server with just the Casting:

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local PartCache = require(RS.Modules.PartCache)
local FastCast = require(RS.Modules.FastCast)
local Caster = FastCast.new()

-- Setting Values...

local BulletTracerProvider = PartCache.new(BulletTracer, 25, workspace.Things)
local CastParams = FastCast.newBehavior()
BulletTracerProvider.ExpansionSize = 30
CastParams.Acceleration = Vector3.new(0, -workspace.Gravity / 3.5, 0)
CastParams.HighFidelityBehavior = FastCast.HighFidelityBehavior.Default
CastParams.CosmeticBulletProvider = BulletTracerProvider
CastParams.CosmeticBulletContainer = workspace.Things
FastCast.DebugLogging = false
FastCast.VisualizeCasts = false


-- Functions...


Caster.LengthChanged:Connect(UpdateRay)
Caster.CastTerminating:Connect(RayDestroyed)
Caster.RayHit:Connect(OnHit)


RaycastEvent.OnServerEvent:Connect(function(Player, Origin, Direction, SpreadX, SpreadY, TravelSpeed, MaxDistance, HeadDmg, BodyDmg, LimbDmg)
	-- Preparing Cast...
	
	local ActiveCast = Caster:Fire(Origin, Direction, BulletTravelSpeed, CastParams)
	
	ActiveCast.UserData = {}
	ActiveCast.UserData.Player = Player
	
	ActiveCast.Caster.LengthChanged:Connect(UpdateRay)
	ActiveCast.Caster.CastTerminating:Connect(RayDestroyed)
	ActiveCast.Caster.RayHit:Connect(OnHit)
end)

If you have any other solutions, I really would like to hear them! But please keep them server sided because i don’t want to deal with all the delays and inaccuracy’s that come from the client.

Is there any way to visualize a projectile’s trajectory while using FastCast? If anyone has any resources, that’d be great.

is there a way to change the parameters of the projectile (cast) after it had been fired? (e.g. cast:SetVelocity(), cast:AddAcceleration() etc)

Hey, @Xan_TheDragon, would you be willing to upload the library to GitHub? Because I found a small issue with the typechecking and wanted to submit a pull request and also, it would allow for other developers to easily contribute new features. Nice module and thanks, beforehand!

Nvm, he seems to have left the platform

Hey everyone. With @Xan_TheDragon’s permission (who I have contacted on Discord), I uploaded the source code for FastCast to GitHub. This should make it easier for others to contribute and suggest features.

1 Like

obviouslt you havent paid any attention at all, this module is amazing, and it doenst just create a gun fro you, but it is very easy to make the bullet move

1 Like

Is fast cast actually being rewritten as the github repo description says?

I am rewriting it. Xan gave me an unfinished and unreleased rewrite he was working on, so I’ll start from that.

Awesome sauce! I might use it. Will it have similar or same API as before?

It will most likely be a similar API.

I’m using it for my gun system so when I get to the raycasting part I’ll update FastCast. There’s features that I’ve thought of adding such as:

  • Parallel Luau
  • Lag compensation
  • Shapecasts (maybe?)

Though I’ll see how I’ll do that.

This is only an issue if you used fastcast incorrectly, the bullets are freezing because when you reset your gun is destroyed and so is the script.

Would you mind making the rewrite repo public? I get its uncomplete but I may want to take a peek at the code.

Even if no shapecasts, spherecast and blockcast would be great.
As well as a way to manually time step, or change the time scale!

1 Like

I’ll see what I can do about that, anyways it’ll be open source so anyone can contribute.

It’s FastCast with less features (as not everything has been ported) but more organized.