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

Nope. You can make your projectiles have any speed you want.

13 Likes

That is quite a dilemma indeed.

The system doesn’t have a method for handling that namely since I had absolutely no idea that it was possible for that to occur.

I’ll have to come up with a way to fix that.

13 Likes

But where does raycasting come into play if the projectiles aren’t just for show?

9 Likes

If you want the projectiles to not only be for show (as in you want to use them for hit detection too), then this module is useless to you.

This module was designed for the express purpose of getting rid of part-based projectiles. Simply put, firing the raycaster should replace the creation of a velocity-based bullet that has touch detection. Likewise, the RayHit event of the raycaster should replace listening to the Touched event on the bullet part.

The reason I had suggested a cosmetic bullet is so that you can still retain the illusion of a physical part being used. You can create an anchored part that looks like your bullet, and CFrame it based on the LengthChanged event’s parameters so that you can put the bullet where the ray is currently located.

If we’re still having trouble understanding each other, I encourage you to message me - that way I can provide a bit more direct clarity on usage, and leave the public forum here to discussion and insight regarding the module’s features.

29 Likes

Yes!! This is EXACTLY what I’ve been needing, thank you so much for sharing this! :heart:

18 Likes

It would be really nice if you could make a Tool that uses your Script and upload it as a model or just have it in an Uncopylocked Place.

I tried reading stuff that you provided but I can’t get my head around it quite yet.

I learn better when I see Example code which is why I’m asking for this.

I know you have an Example Script but I can’t tell which is which, like do you need all of that code to make it work?

I just want a Tool that uses your Module to Fire Bullets as an Example.

Thank you! @Xan_TheDragon

16 Likes

Good idea. I’ll get that done for you. I’ll edit the post when I make it. :+1:

11 Likes

Sorry for being so late.

While I was doing your request, I ran into quite a dilemma: There was no easy way to track cosmetic bullets and their corresponding rays! So as a result of that, I took some time to release Version 5.

To @RuizuKun_Dev - The original post up top has been edited to include the gun you requested, it’s at the very bottom. I do have to thank you for asking about that, since I wouldn’t have realized that problem on my own. +1 for that.

15 Likes

Thanks for releasing this, I’ve been implementing this into my own game, and have been absolutely loving it!

One thing I was wondering about, is if it was possible to get the end position of a cast (before it has even finished), this would assume that nothing has moved into the trajectory of the cast before it has finished, but I was going to use something like this for some cosmetic additions to my weapons, to create a second cast.

7 Likes

How does this perform in comparison to a part with BodyVelocity?

6 Likes

Tests have shown fairly outstanding results.

To put it as simply as possible: The method that this module uses to update the position of the part yields strong benefits, as it does not rely on physics and the woes that can result from the physics system. Since it uses raycasting, hit detection is extremely consistent. This consistency can be lacking on physics-based bullets, especially if network ownership of the part’s physics is not specifically set to a certain client or the server. Most of the time, these kinds of bullets will skip their target or lag just before they hit someone during the transition of network ownership. Better yet, the raycasting is fast and based on the delta-time (amount of time it took to perform a step) so that the bullet won’t be stopped/moved in the event of lag.

Additionally, large amounts of these bullets that use physical simulation can cause lag on the place as there’s a lot of things to update at once. This raycaster is a lot less intensive.

9 Likes

Is it possible to increase the hit detection radius for big projectiles? I’ve tried your module and it only detects when the very middle of the projectile hits something, but in my game there are some fairly big projectiles.

3 Likes

The ray’s current point is designed to simulate the end point of the projectile.

Based on what you said, I’m going to assume you are CFraming a projectile to the position of the ray. If this is the case, you simply need to modify your CFrame to put the bullet behind that point. This is fairly simple, but for the sake of giving proof of concept I’ll supply example code anyway.

You should do something along the lines of this. Assume the bullet is a standard block part. (If it’s a mesh that isn’t using a MeshPart, or more specifically the visual projectile does not reflect the size of the part instance itself, you will need to find this length value for how long the bullet is).

Bullet.CFrame = CFrame.new(RayPoint, RayPoint + RayDirection) * CFrame.new(0, 0, Bullet.Size.Z/2)

This will cause the front of the bullet to be placed at the location of the ray’s current point, thus causing the front of the bullet to be at the point of hit detection. Hopefully this helped you out enough. Just ask if you need anything else.

8 Likes

@Xan_TheDragon

Is there a reason why you do something like

if Tool.Parent:IsA("Backpack") then return end

instead of just

if true then
   Code
end

why are you doing

if false then
   return
end
Code
2 Likes

Would this work work with unique weapons such as firehoses and the boxing gloves from Nintendo’s Arms?

2 Likes

It’s a common coding style. It’s a way to get your edge cases out of the way so you know that the general case code will run correctly.

11 Likes

I thought it would have something to do with performance.

2 Likes

What I meant was if it’s possible to increase the size of the hit detection ray on the x and y axis so the projectile doesn’t go into the ground so much before a hit is detected:

image

I’d like the hit detection to happen when the very edge of the projectile hits something on all sides.

6 Likes

Is this Intentional or an Error?

When you zoom all the way with the Example Gun you provided, when I aimed at the Head it shot at the Body but when you zoom out it shot at the head.


I also want an Answer for this question from you @Xan_TheDragon


@Chaotic_Cody No hard feelings, maybe he has a different Reason.

4 Likes

No problem at all! In fact, it’s great to verify your information with multiple sources.

5 Likes