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

Hey, so I have a problem. Using this with a viewmodel, and it works fine, until I aim in. When I aim in, it hits the gun model so it stops. How can I make it go past and ignore certain models and its descendants?

I know that there’s a function for it, but I can’t find it. Mind telling me what that function is and how to use it? Thanks

Also, forgot to mention, whenever I aim in, the bullets shoot backwards instead of forwards. How do I fix this?

You sir, are a godsend.

Thanks for the clarification on client rendering. I found that many of my issues were solved by just having the client render projectiles.

Is version 13.2.1 published yet? Taking a look at the module and I don’t see PreSimulation / PostSimulation being used anywhere according to your changelogs.

Add the gun parts to RaycastParams.FilterDescendantsInstances assuming it uses a blacklist.

It was but then I pulled it because PreSim/PostSim aren’t live yet.

Hey, quick question again, hey it’s me!

So I tried out some beam work, and two beams together make it look like a super nice bullet. How do I make the fast cast use two beams with of course, two attachments, be the fire point? Or do I just seperate it to make a velocity based beam?

What would be the best way to use this module?

I want to have good hit detection, But when i use this on serverside, The bullets take a bit to shoot.

I’ve seen people say make the hit detection on server-side, But replicate the bullets on the client?

Also: Could this work with viewmodels?

1 Like

I can’t fully explain to you, but I can answer it.

Number 1: Yes, it can work with viewmodels, I use it for my viewmodel.

I usually do the bullets client side then do the damage on serverside, along with maybe another extra caster:Fire() on server to add those serverside bullets so people can see you shoot.

1 Like

If it’s a beam and 2 attachments, Can’t you just put them inside an invisible part, And make the part the bullet? This way the attachments would also follow the part i’d assume

https://gyazo.com/76eabac15e584846e39f1f73087506c3

https://gyazo.com/dcdcd0e249c3a5274caf32e57233a0da
This is how i created the part, This works fine for me (Even though i’m using a trail not a beam, But they should be the same.)

Do you mind sharing the bullet code to add that bullet in? Since I am having trouble with that.

Alright, The code used to clone the bullet is:

local BulletTemplate = game.ReplicatedStorage.Bullet:Clone() -- This will be the bullet we clone.

local CastBehavior = FastCast.newBehavior() -- put your settings here
CastBehavior.CosmeticBulletTemplate = BulletTemplate 

Furthermore, You can use “CosmeticBulletProvider” If you want to use a partcache.

Cheers mate, will try it out in a second.

By the way, Don’t forget you need to update the bullet’s CFrame, The module doesn’t do that by itself.

Hmm?? I used a part cache and it worked fine without changing the CFrame.

Oh?? Strange, I didn’t know that.

Also strange, whenever I shoot the bullet doesn’t move, it teleports right in front of muzzle but doesn’t shoot forward.

local caster = FastCastRedux.new()

local BulletFolder = workspace:WaitForChild("BulletFolder")

local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Blacklist
castParams.IgnoreWater = true

castParams.FilterDescendantsInstances = {BulletFolder}

local bulletTemplate = RS:WaitForChild("BulletPart"):Clone()
--bulletTemplate.Anchored = true
--bulletTemplate.CanCollide = false
--bulletTemplate.Size = Vector3.new(0.08, 0.057, 0.077)
--bulletTemplate.Material = Enum.Material.Neon
--bulletTemplate.Color = Color3.fromRGB(8, 148, 255)
--bulletTemplate.Transparency = 0.99


local bulletCache = PartCache.new(bulletTemplate, 90, BulletFolder)

local castBehavior = FastCastRedux.newBehavior()
castBehavior.RaycastParams = castParams
castBehavior.Acceleration = Vector3.new(0, -workspace.Gravity, 0)
castBehavior.AutoIgnoreContainer = true
castBehavior.CosmeticBulletContainer = BulletFolder
castBehavior.CosmeticBulletProvider = bulletCache
--castBehavior.CosmeticBulletTemplate = bulletTemplate

That’s what i meant, You’ll have to update the projectile’s CFrame, Here’s the code i used.

Caster.LengthChanged:Connect(function(Cast, LastPoint, Direction, Length, Velocity, Projectile)
	if Projectile then
		local ProjectileLength = Projectile.Size.Z/2
		local Offset = CFrame.new(0,0,-(Length-ProjectileLength))
		Projectile.CFrame = CFrame.lookAt(LastPoint, LastPoint+Direction):ToWorldSpace(Offset)
	end
end)

Alright, thanks. It works. I will add in an onrayhit so it deletes the bullet on impact of an object.

1 Like

Unsure if raycast parameters are off or what, but it doesn’t seem to filter correctly??

I get prints when the bullet hits the barrel of the gun (which is a child of “Tool”), thus it should be ignored??

local Tool = script.Parent
local Character = Tool.Parent

local Bullets = workspace:WaitForChild("Bullets")

local CastParams = RaycastParams.new()
CastParams.FilterType = Enum.RaycastFilterType.Blacklist
CastParams.IgnoreWater = true
CastParams.FilterDescendantsInstances = {
	Character,
	Tool,
	Bullets
}

local Caster = FastCast.new()

-- Set up cast behavior
local CastBehavior = FastCast.newBehavior()
CastBehavior.RayCastParams = CastParams
CastBehavior.Acceleration = Vector3.new(0, -500, 0)
CastBehavior.AutoIgnoreContainer = false
CastBehavior.CosmeticBulletContainer = Bullets
CastBehavior.CosmeticBulletTemplate = BulletTemplate

local function OnRayHit(cast, result, velocity, bullet)
	local Hit = result.Instance
	print(Hit)
	local HitCharacter = Hit:FindFirstAncestorWhichIsA("Model")
	if HitCharacter ~= Character then
		if HitCharacter and HitCharacter:FindFirstChild("Humanoid") then -- Character
			HitCharacter.Humanoid:TakeDamage(100)
		end
	end
	
	Debris:AddItem(bullet, 2)
end

Caster.RayHit:Connect(OnRayHit)

Is there a way to make the projectile and the end result different parts. By that I mean, can the projectile that flies through the air be a specific part, with its own specs, and then the bullet that is left on the part be a different part?? I want to use rectangle projectiles, but then have the part that sticks on the block be a ball :confused:

1 Like