FastCast & CanQuery

I am currently using FastCast module to create projectiles and I’ve encountered an issue. I have Zone Objects placed around in my Workspace and all of them are set CanCollide - Off & CanQuery - On.

Now there is a reason for having CanQuery- On, I want to handle Zone Enter Events & Zone Exit Events.

CanCollide - Off property is set to false since players are supposed to go through those Zones.
Okay, so now I have projectiles that I can Fire by using FastCast.

FilterDescendantInstances contains all Zone Objects.

Apparently, the projectile “does” work when I try to shoot from a far distance through the Zone Object, however if I get closer to the edge of the Zone, the projectile fires in different directions!

Setting the CanQuery - Off would fix this issue, but my Zone Enter Evenets & Zone Exit Events won’t work… :slightly_frowning_face:

3 Likes

I’m not entirely sure how either Roblox or the FastCast module handles raycast collision, but maybe if you put the raycasts in another collision group, that would fix it? Sorry if that’s not possible with raycasts, but it’s the first thought given my limited knowledge of raycasts.

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude --> don't change with blacklist or white list because not working.
raycastParams.FilterDescendantsInstances = { -- enter your ares which you want }


for _, zone in ipairs(zonesFolder:GetChildren()) do
    table.insert(raycastParams.FilterDescendantsInstances, zone)
end

Can this helpful?

1 Like

I am not that familiar with fastcast but you can give it if this may work:

  1. Is there some blacklist/whitelist you may can use within fastcast to allow certain objects to work?

  2. Maybe using Collectionservice and tag system, you may can allow a custom tag to be allowed without effecting all other zones if this is not build in within fastcast.

Let me know how things go, I be gladly think along side with you! :wink:

I’ve already said that it contains them.

This is what I was thinking of, not collision groups! Although, I think RaycastParams comes from the Roblox API, OP said he was using FastCast, so he’d have to find the equivalent in FastCast.

I also tried different Collision Groups. I can’t set the Zones to any other than Default since I am using Zone Plus module for them.

I’ve tried setting the projectile part to “Cast” Collision Group, so I did this part of the code.

PhysicsService:RegisterCollisionGroup("Cast")

PhysicsService:CollisionGroupSetCollidable("Default", "Cast", false)

However, this doesn’t make any changes either.

Have you considered temporarily (for the duration of the cast) making the zones CanQuery = false?

I have already set those. Here is the sample code.

--// Set
local CastParams = RaycastParams.new()
local CastBehavior = FastCast.newBehavior()

--// Configurations
CastParams.FilterType = Enum.RaycastFilterType.Exclude
CastParams.IgnoreWater = true

CastBehavior.RaycastParams = CastParams
CastBehavior.Acceleration = Vector3.new(0, -Workspace.Gravity / 5, 0)
CastBehavior.CosmeticBulletContainer = VFXStorage
CastBehavior.AutoIgnoreContainer = true


local FilterList = {Character, VFXStorage, Int_LocationsFolder}
for _, Zone in CollectionService:GetTagged("Zone") do
    table.insert(FilterList, Zone)
end
for _, TeamFolder in TeamService.GetTeamFoldersExcept(Player) do
    table.insert(FilterList, TeamFolder)
end

CastParams.FilterDescendantsInstances = FilterList
CastBehavior.CosmeticBulletTemplate = DefaultCasts[Element].Bullet

local Cast = Caster:Fire(Origin, Direction, 100, CastBehavior)
1 Like

It’s not a good idea to do this, since I wanna track everything perfectly and independently. It would be redundant.

What about forking ZonePlus to make the zones use a different CollisionGroup?

1 Like

i used fastcast and zoneplus too. this seems correct to me.
have you tried testing without having the bullet and vfx? i doubt the bullet/vfx may have collision/query that might mess up the raycasts.

Bullet has none of the settings set to true.

CanCollide - False
CanQuery - False
CanTouch - False

But I can definitely try to just use a visualizer!

if the zones are static and not changing or moving, then you may try Zone:relocate()
it moves the zones out of workspace so fastcast cant see them
but players should still be able to enter/exit zones

1 Like

Some of the Zone Objects do move unfortunately. Such as obstacles.

I’ve also tried only using Visualizer without the Bullet, and the issue stays the same.

It doesn’t change anything, I tried to set even the Default one to false, it’s the same.

just curious, if the “direction” is wrong, then it is nothing to do with fastcast/projectile in the first place, isnt it?
your filter is applied to the projectile trajectory for it to determine if it hits something or not.
BUT the initial shoot direction, how did you do it? does it use raycast ? if it does, have you applied the same filter?

1 Like

This code is in Loop? it is important

This, there is likely something wring with the aiming protocols. It is probably aiming at the part of the zone object you are aiming at, not aiming behind it. You likely need to adjust the raycast parameters for translating the mouse position into a target.

It uses the simple Direction math.

NetClient_PlayAbility:Connect(function(Player, Data)
    --// Define
    local MousePosition = unpack(Data)

    local Element = Player:GetAttribute("Element")
    local Character = Player.Character
    local Root = Character.HumanoidRootPart

    local Origin = Root.Position
    local Direction = (MousePosition - Origin).Unit
1 Like