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

Yeah that’s the way you do it. Effectively assign guns a lookup from gun → caster.

Just remember to not send the gun type over the event, as that is a gaping security hole. The server should know what gun someone is using already.

1 Like

Not sure if its a problem with FastCast or my use of it, but AutoIgnoreContainer will add the CosmeticBulletContainer to the RaycastParam table, even if its set to whitelist.

Here in the API it states it will not work if its using a whitelist. This caused my bullets to hit each other, and setting AutoIgnoreContainer to false fixed it for me.

This is the way I was using it.

	local RaycastParam = RaycastParams.new()
	RaycastParam.FilterType = Enum.RaycastFilterType.Whitelist
	RaycastParam.FilterDescendantsInstances = {workspace.CurrentMap.Decor, workspace.CurrentMap.ObstacleHolder}
	FastCastBehavior.RaycastParams = RaycastParam

	FastCastBehavior.CanPierceFunction = CanPierce
	FastCastBehavior.CosmeticBulletContainer = workspace.fastCast

It shouldn’t, as the API member states. Though technically, “will not function” does imply that it just won’t work as you expect in general.

How can I access a bullet that has been released? For example, to change the color of the bullet at the time of flight.

Does this work if i use models as bullets?

I’m using fast cast for my mech game and I’m having a few problems I just want to know if it’s me or just limitations of the module.

My mech character can wield up to 4 guns simultaneously and fire simultaneously. In studio this is not an issue but in live servers even having only two players with the same loadout makes ping start to skyrocket.

Do we have any stress test references to see if it’s just me or limitations of the module?

Probably worth noting that the weapons have a pretty high fire rate of around 1 shot every 1/100 of a second.

I find it hard to believe that fast cast would have trouble with 8 high fire rate guns so I’m hoping it’s just me and my terrible code…

1 Like

Fast cast doesn’t use remote events or deal with networking at all so it should be up to user implementation.

Remote events is usually what causes Ping to sky rocket depends on rate and the amount of information you are sending.

Also automatic replication from server → client can cause ping to sky rockets which I have learnt from @Alvin_Blox problem, ex: creating part from server.

Perhaps you are creating the bullets on server with part cache being on the server?

1 Like

Well one thing may have been that each gun had a part cache of 500 rounds. I brought this down to 50 as I suppose that was an extreme overestimate.

However, I’m not sure what you mean by

Aren’t bullets meant to be apart of part cache on the server?

Nope, not necessarily. For my game the fastcast is on the client to handle the visuals only.

If it is on the server then everything has to replicate to the client including the bullets projectile motion for every position and orientation changes.

Vs telling the client once to create the bullet and then letting the client simulate by itself without needing the server to tell it every position and orientation change as the bullet travels.

I recommend you try it out yourself and see if it makes a difference.

This method of using fast cast on the client for client effects I took notes from FPS framework 2.

Isn’t this method vulnerable to exploiters though?

Also you mention the client handles the visuals. But if the client handles the visuals, how will the client see other clients bullets?

You could do this from detecting when the player shoots the gun, then the server will send data’s of the bullet (e.g: Origin, Direction, Velocity, etc) from the player that shoots to other players to draw the visuals (e.g: bullet model, bullet trace, etc), so basically

Client → Server → Other Clients

i can concur. Beastybeasty145’s comment is very useful for the task in my hand.


The issue appears to be workspace being nil.
What’s happening here? Do bullets have to be parented to something specific?

I decided to go with your advice and I managed to get some really interesting results. Send-Receive rates of under 1KB/s for both clients on both rates. However my only issue now is that spread is of course randomly generated which means that if the spread isn’t accurate enough for the receiving client, the attacking player will have killed the client but the defending client would be fine which is less than ideal. Thanks for the advice, Ill do my best to develop this system but I am not without my concerns as I am sure how to defend against exploits through this way.

1 Like

If anyone wants the provided Example Gun into a direct ServerScript, you can view how I did this here!

any good way to get spirals or circular motion? I’ve read that it could be a bad idea to update the cast physics every frame. assuming at most 50 projectiles on the screen, how expensive could this be? am I better off just using traditional hit detection?

Is there any way of simulating the ray instantly?

I’ve tried figuring this out myself, but haven’t been able to…Does anyone know why when the FirePointObject on the Tool seems to either collide or be very close to colliding with another part, the bullet will fire at a completely different angle?


Sorry for the small Gif, but this showcases what I mean. You can see my first few bullets fire in random directions when touching or nearly touching another object, as well as the last few bullets. You also see one shot actually go in the correct direction when I’m further away from the object.

3 Likes

Is it possible to simulate air resistance and drag with FastCast?

1 Like

This is a roblox issue with cursor detection sadly.
I personally have this issue with EVERYTHING thats cursor-based.

As far as I am aware there is no direct solution (I may be wrong)
You could attempt the following though.
~ Raycast from the camera origin to get the hit cframe of the mouse. (unsure if this will work.)
~ Or just detect if the gun is very close to something and make it shoot infront of the barrel by default instead of going to the cursor.

2 Likes