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

Didnt try it.
here is my changed MouseEvent in the script

MouseEvent.OnServerEvent:Connect(function (clientThatFired, mouseDirection)
	if not CanFire then
		return
	end
	CanFire = false
	Fire(mouseDirection)
	Fire(mouseDirection)
	Fire(mouseDirection)
	Fire(mouseDirection)
	Fire(mouseDirection)
	wait(FIRE_DELAY)
	CanFire = true

end)

Well, I’m still not sure why mine isn’t working.
The biggest difference I can see is that I’m firing my FastCast function fully on the Client, not Server. (Assuming your ‘Fire’ function is just creating a FastCast)

Jeah, don’t fire from the client, it won’t work then.

Why not, that’s what I’ve always done?
All the other weapons work fine (pistol, smg), It just won’t fire more then one bullet at a time for some reason.

Hey! I’m making a game that will feature quite a few ability-based projectiles, and I’m working to use FastCast for that purpose. My current plan for integrating FastCast is to set up a caster object for each individual ability and having every entity (NPC, player, etc.) that uses that ability use that specific caster object. Is this the proper way to go about it? Or should I be creating entity-exclusive casters instead, such that every player/NPC/whatever has their own ability casters?

@Paintertable Using the system itself from the clientside causes no problems for it, it’s designed to work on both (in fact, you can see evidence of this on the if statement located at line 140 and ending at line 144. I don’t know if this is what you meant to say or not, but I’ll bring it up just in case.

if RunService:IsClient() then
	targetEvent = RunService.RenderStepped
else
	targetEvent = RunService.Heartbeat
end

@ChefJustice Yep! This is one way to go about it. Do be careful when tracking which NPC/Player has used the ability! The same LengthChanged and RayHit functions will fire for everyone if you implement it this way. I recommend instantiating a caster every time the ability is referenced so that each NPC/Player has their own, unless you are comfortable with handling that event call differentiation on your own. There are pros and cons to both, but otherwise there will be no negative impact in terms of performance.

2 Likes

What would be the benefit on doing it on the client? Would the projectiles be more smoother?
Currently the projectiles don’t fire from the bulletpoint directly and spawn (or are visible) some studs later. (ofc they spawn at the bulletpoint but they aren’t visible instantly which makes it looks weird sometimes.)

This is genuinely a lifesaving module, thank you. Any future plans for projectile ricochet?

1 Like

you can make the bullets ricochet using the module. just make it so when it hits something it fires the same bullet in a different direction. if you don’t know what direction to make the bullets go, this thread might help

2 Likes

This module is amazing! Thank you so much for making it

One issue I had was the bullets seemed to be ‘starting’ one segment ahead of the origin position, I found that this was because the initial totalDelta in the Fire function being 0, so the GetPositionAtTime function is multiplying the calculations by 0, therefore positioning it at 0, 0, 0 initially. Changing the initial totalDelta variable to something small like 0.00001 fixed it at bullets now spawn out of the origin position

Edit: you also need to move the totalDelta calculation as shown below

original:

edit:

3 Likes

Thanks alot! This made it alot better for me! But its still not very smooth. I have the feeling that the bullets have some lag. Do you create the bullets on the client to have it look smoother or the server?

I handle the visual side (bullets) on the client, bust I also use fastcast on the server (with no visual bullet) to handle damage. Looks smooth for me!

Can you tell me how you do it? ( Maybe in private chat if this floods the post )

In short
-on firing from client create a fastcast bullet for the local player
-send event to server saying the player fired, create fast cast on server with no bullet (have to edit module a tiny bit, just commenting out some checks)
-send event to other players that player created a bullet, on client create fastcast from the firing players weapon
-handle damage on server from fastcast bullet hit event

If that doesn’t make any sense dm me, I’m on mobile at the moment so I can’t show any example code

2 Likes

Is there any way to always have the bullet come from the attachment every time? I made the spread 0 and it still spreads noticeably if you don’t click anywhere near the center.
https://gyazo.com/06de32e0a1d6179b319bc7dad7f9ea7c

6 Likes

I just noticed this, FireWithWhitelist and FireWithBlacklist functions do not pass on the canPierceFunction to the BaseFireMethod function; so it is nil every time.

Oh! Good catch! I’ve just released a patch for that in v9.0.1. Reinserting the model should fix it.

2 Likes

Is there a way to use fast cast to cause the cosmetic object to home in on a part? In other words I want to create a missile to change directions and follow a part based on the position of the part.

Is there any way to make the projectile come out in a straight line from the fire point and not at mouse point? I looked at the API and messed with it in studio a bit and I can’t seem to get it off mouse point as the direction.

You would most likely use CFrame.LookVector