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

Yeah I don’t know why that was removed… Hm. I think it was for something in debugging to test the odd pierce behavior reported some ways above.

It’s been re-added.

I can say one thing is that and does not join arrays together. In Lua, and will select the only non-nil operand, and if both are not nil, it always selects the operand on the right (so in your case blacklist is only Cannon:GetDescendants() and nothing else).

Inside of the FastCast module is a utility module called “Table”. You can use this if you’d like, simply do local table = require(FastCastModuleHere.Table). After you have my custom table module overwriting the stock table option in scripts (via that line just above), you can use table.join(projectiles:GetDescendants(), Cannon:GetDescendants())


Those replies aside, FastCast 10.0.2 has been released to fix the bug mentioned just above. Additionally, there is now a prototype of the module that uses’s the Luau Strong Type Beta feature included in both models! This should ideally run faster than the actual module (though I don’t think the speed increases will be that notable). Do note that this will not work in live games yet, and you need to enable the beta feature to actually use the module in the first place.

1 Like

I got bullet reflecting to work! This module is legit a lifesaver. I tried several physics based approaches previously and none of those methods worked nearly as good as this has so far. The crazy part is that I can combo automatic fire, fast firing speed, shotgun pellets, and have all those bullets ricochet and it’s still fast - literally no lag. Just feels so unbelievable. Thank you so much for making this!

9 Likes

Awesome work! I’ll release a feature for this officially when I release the ability to alter trajectory during runtime (so it will be using considerably different code than what you have).

The only real issue developers may face is that this is going to be yet another complete restructure of the API + events. I’ll get into the details later down the line, but the basic gist is that casts that are currently being simulated will be their own objects.

1 Like

How would you go about adding a recoil to this? Or did I overlook the module and missed where I could have learn about it?

Will you be updating the module to support the new method of casting rays?
WorldRoot:Raycast() which also takes RaycastParameters and returns RaycastResults?

https://developer.roblox.com/en-us/api-reference/function/WorldRoot/Raycast

Maybe. I don’t know. It depends on how necessary it is. For recognition of modern API? Sure. If I do it, I’ll make a caster able to work in certain specific world contexts too for support in things like ViewportFrame, but that’s for later.

Alright I’ve been doing some API changes for the update that allows redirecting the cast in realtime. This is not live yet, just in the works.

Here’s what I have so far, if you all think I should add or change something, let me know.

First things first. Under this new update, calling Caster:Fire() will now return an instance of a new type called ActiveCast. ActiveCast offers a number of important methods, including:

  • ActiveCast:GetPosition, ActiveCast:GetVelocity, and ActiveCast:GetAcceleration (as well as methods to set this data too). There is also AddVelocity and AddAcceleration for gradual changes.
    • These methods will allow you to alter the trajectory during runtime. Should be self-explanatory.
  • ActiveCast:Pause, ActiveCast:Resume, and ActiveCast:Terminate
    • Pause and Resume should be self-explanatory. A paused cast will be frozen and not simulate. Events will not fire, and the bullet will not move nor will time increment.
    • Terminate will cause a cast to end early. It has a boolean parameter called skipRayHitCall which, if true, will cause the RayHit event to not fire when the cast is terminated. If false, the RayHit event will fire with its default empty args, exactly like when a cast times out and hits its maximum distance.

Secondly, events are changing just a bit. The core Caster object will still have its RayHit and LengthChanged events, with the exception that their first parameter will be a reference to the ActiveCast that caused those events to fire. On top of this, ActiveCast instances now have their own separate events for RayHit and LengthChanged that function identically to what you are used to right now.

On top of this, I’m adding methods to dispose of casters. There is an instance leak for the signal objects. calling this new dispose method will delete the bindables that are used for events.

Any opinions on this structure? Anything that should be changed?

3 Likes

I have made a grappling hook with this fast cast module, you can check it out here.

2 Likes

Finally got FastCast to not be framerate based. This gif should show it well. Sometimes it has a few small wonky points which I have no idea whats causing them
YNpL0FfVwt

5 Likes

You added a way to manually enforce resolution? …Interesting, I could get that added later on. That could be very beneficial.

1 Like

I’ve been having trouble getting this to fire models instead of parts. The projectile glitches out and I can’t orient it properly. Any ideas on how to achieve this?

1 Like

Hey man @EtiTheSpirit !

Roblox added a new feature New RaycastParams Property, Deprecating Old Raycast Functions

It’s also interesting to see people make the rays reflect, that should definitely be added to the Module, you should consider putting it on Github

So ive been using fastcast for my fps game and just ran into this problem today

ive tried anchoring and unanchoring, putting the bullet part position to 0,0,0 and turning on and off can collide, but the the bullet part still seems to be coming from under the map?
has anyone else encountered this problem before? this all seems to have come completely out of the blue and there are no errors in the output so i really have no idea.

1 Like

I had this problem aswell and the way I fixed it was by using this Model | Documentation - Roblox Creator Hub
Example: Bullet:SetPrimaryPartCFrame(CFrame.new(FirePointObject.WorldPosition, FirePointObject.WorldPosition + Direction))

But basically i just switched it to setting PrimaryPartCframe(the primary part value of a model) instead of setting a parts cframe and this fixed it.

NOTE: this was done on a way older version of this module so it might have to be used somewhere else now.

1 Like

@EtiTheSpirit
Hey!
I’m making a bow system, and I have it so it charges it per second * 100 for the speed.
So:

speed = math.ceil(timeHeld) * 100

This doesn’t seem too good. Any help on a better formula?

Thank you,
recanman

i got a problem where ive added terrain water to the if statement (enum.material.water) of what the debug gun can pierce. but then once it goes through terrain water it goes through all terrain. any way to fix this?

@isaiahbur maybe delete the round if it encounters water terrain by editing the onTouched function?

@isaiahbur I tried that method a while back but it didn’t work. The Model fires in the right direction, but the cosmetic bullet jitters all over the place and is not rotated properly

I’ve addressed this three times in this thread. Two of these times have been spent responding to you. See Reply #254 and Reply #278. My answer is the same as it was there before. Please stop asking, it’s not adding anything good to this thread. https://www.youtube.com/watch?v=0d6yBHDvKUw.

Try something like this. A minimum of 0.2 means that if they click and instantly let go, they get some speed (but very little). maximumTimeHeld should be what the variable name describes - the longest time you can hold it. If you hold it for longer than this value, you get no gain.

speed = math.clamp(timeHeld, 0.2, maximumTimeHeld) * 100

cc @ExHydraboy

Yes, use the dedicated ignoreWater parameter. Do not add water as a material.

Terrain is a single BasePart. Once it is added to the blacklist by any material, the entire terrain will be ignored.

3 Likes

@EtiTheSpirit I’m really sorry for constantly repeating the same thing over and over. I forgot about the replies.

I’m actually interested in the Github bit more than updating the Module as it is already functional.

I really like the Module and I want it to be the best.

Sorry again for the nuance.

2 Likes