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

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?

Hey, so I’m using your module for a game I’m making, but I keep running into this problem where the bullets get stuck mid-air.

Here’s what it looks like:

Here is the code:

local wizardNPC = script.Parent.Parent
local wizardHRP = wizardNPC.HumanoidRootPart
local wizardRightHand = wizardNPC.RightHand
local FirePointObject = wizardRightHand:WaitForChild("GunFirePoint")
local FastCast = require(wizardNPC.FastCast.FastCastRedux)

local CosmeticBullet_Folder = wizardNPC.CosmeticBullets
local ignoreList = CosmeticBullet_Folder:GetChildren()

local RNG = Random.new()
local FIREBALL_SPEED = 900
local FIREBALL_MAXDIST = 4000
local FIREBALL_GRAVITY = Vector3.new(0, -100, 0)
local MIN_FIREBALL_SPREAD_ANGLE = 0
local MAX_FIREBALL_SPREAD_ANGLE = 0
local FIRE_DELAY = 1
local TPI = math.pi * 2

local CanFire = true

local Caster = FastCast.new()
local CosmeticBullet = CosmeticBullet_Folder:WaitForChild("fireball")


function Fire(direction)
	
	local directionalCF = CFrame.new(Vector3.new(), direction)
	
	local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TPI)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_FIREBALL_SPREAD_ANGLE, MAX_FIREBALL_SPREAD_ANGLE)), 0, 0)).LookVector
	
	local movementSpeed = wizardHRP.Velocity
	local modifiedBulletSpeed = (direction * FIREBALL_SPEED) + movementSpeed
	
	local bullet = CosmeticBullet:Clone()
	bullet.CFrame = CFrame.new(FirePointObject.WorldPosition, FirePointObject.WorldPosition + direction)
	bullet.Parent = workspace
	
	Caster:FireWithBlacklist(FirePointObject.WorldPosition, direction * FIREBALL_MAXDIST, modifiedBulletSpeed, ignoreList ,bullet, wizardNPC, false, FIREBALL_GRAVITY)
	
end

function OnRayHit(hitPart, hitPoint, normal, material, segmentVelocity, cosmeticBulletObject)
	
	CosmeticBullet:Destroy()
	
	if hitPart ~= nil and hitPart.Parent ~= nil then
		
		local humanoid = hitPart.Parent:FindFirstChild("Humanoid")
		
		if humanoid then
			
			humanoid:TakeDamage(5)
			
		end
	end
end

function OnRayUpdated(castOrigin, segmentOrigin, segmentDirection, length, segmentVelocity, cosmeticBulletObject)
	
	local bulletLength = cosmeticBulletObject.Size.Z  / 2
	local baseCFrame = CFrame.new(segmentOrigin, segmentOrigin + segmentDirection)
	cosmeticBulletObject.CFrame = baseCFrame * CFrame.new(0, 0, -(length - bulletLength))
	
	
end

wizardNPC.AttackPlr.Event:Connect(function()
	
	CanFire = false
	
	Fire((wizardRightHand.CFrame.LookVector).Unit * FIREBALL_MAXDIST)
	wait(FIRE_DELAY)
	CanFire = true
	
	
	
end)


Caster.LengthChanged:Connect(OnRayUpdated)
Caster.RayHit:Connect(OnRayHit)

I’m somewhat new to scripting and this is kinda my first time using this module so if anybody could point out the errors in my script I would appreciate it!

Edit:
I also noticed that the script breaks whenever I use Caster:FireWithBlackList() instead of Caster:Fire(). But whenever I use Fire() it creates a weird effect where it spawns 2 bullets instead of 1