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

Yeah this is definitely something with Luau. I get it too and it’s because of importing strong types as far as I can tell.

2 Likes

I’ve got a question. For some reason my bow won’t fire in the proper direction. The gray part is the position my arrow should hit, but for some reason it just shoots straight up?

I’m not really sure what I’m doing wrong here. This is basically my code:

local TargetPosition = Mouse.Hit.P --FYI this is all on the server. I'm just using this so you can easily see what TargetPosition is.
local Velocity = 1000
--
local FastCastBehavior = FastCast.newBehavior()
--Edit FastCastBehavior:
FastCastBehavior.RaycastParams = BowRaycastParams --BowRaycastParams.TargetBlackList = {Character, Bow}.
FastCastBehavior.MaxDistance = 10000
FastCastBehavior.Acceleration = Vector3.new(0,-50,0) --Simulating gravity hopefully.

Caster:Fire(Arrow.Position, TargetPosition, Velocity, FastCastBehavior)

I must be missing something.

1 Like

im pretty sure the velocity parameter takes a vector3, haven’t looked at the API so don’t quote me on that

It takes both Vector3 and Number, its a variant input.

1 Like

Do you see anything I could be doing wrong here? I’m confused

Is your mouse’s target filter setup properly? It looks like it’s clicking on the bow itself.

A workaround is if you add “–!nocheck” it won’t even start to check it.

edit: but also, it won’t check it. So any warnings won’t be highlighted.

1 Like

TargetFilter seems to be working. I just made it so the gray part moves to TargetPosition on the server:

It’s like somehow TargetPosition is getting lost in translation? This is my code:

BowManagerServer.ShootBow = function(Player, TargetPosition)
	game.Workspace.TestPart.CFrame = CFrame.new(TargetPosition)
	local Character = Player.Character
	local Bow = Character:FindFirstChild("Bow")
	local Arrow = MainGame.GenericFunctions.FindFirstDescendant(Bow, "Arrow")
	if Bow and Arrow then --Bow and Arrow? Get it? No pun intended :)
		BowRaycastParams.FilterDescendantsInstances = BowManagerClient.GetBlackList(Character) --This returns an identical TargetFilter to the one the mouse is using.
		BowRaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		Caster:Fire(Arrow.Position, TargetPosition, BowSettings.Velocity, FastCastBehavior)
	end
end

I’m not sure what else it could be. ¯\(ツ)

Oh my gosh… I finally fixed it and it was simple too.

I was just passing the mouse’s position and not the direction the mouse was pointing. Oops. I copied a line from the example code and now it works like a charm. Thank you for putting up with me

Caster:Fire(Arrow.Position, (TargetPosition - Arrow.Position).Unit, BowSettings.Velocity, FastCastBehavior)

1 Like

Do you know why it’s like this? I had the module working fine a week ago.

Having trouble using the FireWithBlacklist function
Can’t seem to get it to work and can’t find it anywhere on the API page

My code looks something like this right now:

local direction = (direction - tool.BodyAttach.GunFirePoint.WorldPosition).Unit

local directionalCF = CFrame.new(Vector3.new(), direction)
local direction = (directionalCF * CFrame.fromOrientation(0, 0, RNG:NextNumber(0, TAU)) * CFrame.fromOrientation(math.rad(RNG:NextNumber(MIN_BULLET_SPREAD_ANGLE, MAX_BULLET_SPREAD_ANGLE)), 0, 0)).LookVector

local arrow = caster:FireWithBlacklist(tool.BodyAttach.GunFirePoint.WorldPosition, direction, BULLET_SPEED, cs:GetTagged(“Hat”), CastBehavior)

FireWithBlacklist was removed in v11 (albeit not documented properly) because RaycastParams now has the option to swap between a whitelist or blacklist. Simply alter your RaycastParams instance accordingly, and use Fire.

1 Like

Having Trouble With Blacklisting Player, Already Changed From FireWithBlacklist To Just Fire.
C = Player.Character, This Is From Fire() Function In My Server Script Allowing Player To Shoot A Bullet

	local CastParams = RaycastParams.new()
CastParams.IgnoreWater = true
CastParams.FilterType = Enum.RaycastFilterType.Blacklist
CastParams.FilterDescendantsInstances = {c}

for i,v in pairs() do
	if v:IsA("BasePart") or v:IsA("MeshPart") then
		table.insert(CastParams.FilterDescendantsInstances,v)
	end
end

CastBehavior.RaycastParams = CastParams

table.insert(CastParams.FilterDescendantsInstances,v)

This does not work. You must set CastParams.FilterDescendantsInstances to a new table with the = operator.

BTW Im Using The Server Script Of The Template Gun (Edited)
I Did it but it still Damages the Player?

local CastParams = RaycastParams.new()
CastParams.IgnoreWater = true
CastParams.FilterType = Enum.RaycastFilterType.Blacklist
CastParams.FilterDescendantsInstances = c:GetDescendants()

CastBehavior.RaycastParams = CastParams

I believe it is like this since it takes the descendants of the object, and it uses {} because its a table too, so you can put more thatn 1 object.

CastParams.FilterDescendantInstances = {character}

I Tried That And It Did Not Work, I Looked For Ray-casting Filter And It Shows The Person Coding Like My Previous Post.

CastParams.FilterDescendantsInstances = c:GetDescendants()

Is there a way for Fast Cast to store Bullet Data IE, Damage, Player That Fired, ECT?

Yes, have a look at ActiveCast.UserData.

This can be altered like so:

local cast = Caster:Fire(...)
cast.UserData["MyCustomThing"] = 12345
-- ...
1 Like

This model is crashing when I try to insert it. I read somewhere above to disable some beta setting, but I’m not enrolled in any beta settings anyways. How do I get this INTO my game? You definitely need to update OP with precautions on how to actually insert this if this bug is still there