Alternative to CanQuery

im currently working on an isometric dungeon crawler like game which involves guns, the way the guns work is by having the orientation of the character constantly point towards the position of the mouse which works very well on a flat environment. This however, introduces another problem and that is the position rapidly updating when the mouse goes over all wall making the player snap and making aiming rather hard and clunky. Turning of CanQuery fixes this but with the downside of making my walls, Well… Not walls since I have to turn off CanCollide too. Is there any alternative to CanQuery that can achieve the same effect? i have attached an example below, thank you.

1 Like

Yes, raycasts accept a RaycastParams object.

1 Like

I dont quite understand, how would I apply that? can you provide abit more info?

1 Like

When you perform a raycast you get 3 parameters

workspace:Raycast(origin, direction, params)

3rd one is params and you can create that by doing

local params = RaycastParams.new()
params.FilterDescendantsInstances = {}
params.FilterType = Enum.RaycastFilterType.Exclude

In FilterDescendantsInstances table you can put in the wall(s).

1 Like

ohh ic like raycasting from the camera to the direction of the mouse and ignoring the walls? then getting the position of the point where the raycast hit and using that instead?

2 Likes

You could use Collision Groups and make a group for mouse raycasting that does not collide with a group the walls are in.

2 Likes

You have two possibilities, here, first being, you create some folder with stuff that needs to be ignored, and in your RaycastParams, you can add that folder to the FilterDescendantsInstances array. Or, you could use CollisionGroups, and in your RaycastParams, specify which CollisionGroup it should use.

1 Like

I would recommend CollisionGroups since you won’t have to make every wall into the table, and just setting the walls’ CollisionGroup once. Here’s how you can set the params:

local params = RaycastParams.new()
params.CollisionGroup = "(the collision group name)"

And then making the ray:

workspace:RayCast(origin, direction, params)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.