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

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

Thanks! This will definitely help with my bow weapon.

@EtiTheSpirit Sorry to bother you but could you possibly point me in the right direction in regards to firing Models comprising of mesh parts? I have the projectile itself firing, but after a certain number of shots all projectiles become glitchy and visually unstable; also they aren’t rotated properly. I’ve tried everything from CFrame.Angles to welding pre-rotated meshes together. I haven’t found any helpful resources and honestly this sub-forum is my last resort. Any help from Eti or anyone else is immensely appreciated

2 Likes

How could I make it so the projectiles completly ignore parts that are canCollide false?

I know the piercing function exists, but the bullet disappears when it hits the part

EDIT: Nevermind, I had the bullet canCollide true and anchored false

Good module, but i have a problem. I want give a damage and at same time pierce enemy. How i would do it?

1 Like

This is not possible right now. I’ll get this feature added in 11.0.0!

Wait what’s the point of multiplying it by 2?