Introducing generalized shapecasts

Due to the nature of the way shapecasts work. I’m guessing a cone cast is still relevent because a shapecast will make a cone shaped mesh look more like a cylinder if the direction value is used accordingly. If anyone can correct me on this that’d be helpful.

It just would be nice to have a fast method for detecting if something is within “view” of say another object, like an NPC, or a targetting system.

17 Likes

Uh so the shapecasts ignore the precise convex decomposition property of mesh and unions, it will always use the default collision, and it’s kinda annoying for projectiles, will this ever be fixed?

18 Likes

PLEASE add visualisations for raycasts for developer debugging reasons! It’s super inconvenient trying to check to see if our raycasts are being done in the correct manner.

88 Likes

Does WorldRoot:GetPartsInPart() supersede WorldRoot:GetPartBoundsInBox()?

No… alright, so no.

17 Likes

They use whatever the current decomposition geometry is. Precise mode should work - can you provide a repro?

18 Likes

You can use existing Gizmo libraries to achieve the same effect, this is the one I use:

18 Likes

Tested it and it seems like they’re not supported; it errors with “vector too long” whenever EditableMeshes are used. Since this feature works brilliantly with normal meshes, this should be a priority.

16 Likes

Even though it’s possible to create visualizations on your own, Roblox should still provide visualizations for convenience and also so you can be sure the visualizations are correct.

20 Likes

Agreed, I usually make my own visuals, but this would be much more convenient

17 Likes

This is big! This definitely simplifies the process of executing more complex world tasks. :+1:

14 Likes

This is awesome and extremely useful.

Is there any ETA on when we’ll get margins? We’re approaching an entire year since the release of Blockcast and Shapecast, and in that announcement, you guys said you were going to add margins. You also mentioned later that margins were being worked on in parallel with Shapecast. We’ve got Shapecast now (which again, is great), but we’re still hearing that margins are on their way. So, any idea when they might actually arrive?

22 Likes

Here’s some code for some quick visualizing.

local obj = workspace.obj



local dist = 10

local params = RaycastParams.new()
params.FilterDescendantsInstances = {obj}

local clone = obj:Clone()
clone.Parent = obj
clone.CFrame = obj.CFrame
clone.Transparency = 0.5

game["Run Service"].RenderStepped:Connect(function(dt)		

			local dir = obj.CFrame.LookVector
			local shapecast = workspace:Shapecast(obj, dir * dist, params)
			if shapecast then
				clone.CFrame = CFrame.lookAt(obj.Position,obj.Position+dir) * CFrame.new(0,0,-shapecast.Distance)
			else
				clone.CFrame = CFrame.lookAt(obj.Position,obj.Position+dir) * CFrame.new(0,0,-dist)
			end
end)


22 Likes

Margins as soon as possbile please :pray:

18 Likes

I will be using a cat model to raycast now…

jokes aside, great update

16 Likes

They have provided all the required objects to create performant debug gizmos (which is what ceive im gizmo was designed to be)

It looks like theyre using the same method that ceive im gizmo does with using wireframe handle adornments

15 Likes

Big +1 for this, we already have studio settings for highlighting physical assemblies and sleeping parts. It’d be great to actually see every raycast without having to boilerplate visuals in.

One problem I can think of is the CameraModule raycasts, but those can be ignored (I’m pretty sure they still infamously use workspace/FindPartOnRay).

16 Likes

This is going to reduce furniture placement systems to like 50 lines of code lol

17 Likes

I did actually find one somewhat good usecase for having shapecasts not detect parts within their starting position.

This was actually somewhat useful to create really weird non-primitive hitboxes.

This is perhaps a very weird and niche usecase but I actually liked being able to do this with shapecasts.

If you do a super short shapecast it sort of does an “negative union” thing with itself which can be quite useful in some specific cases.
You can use stuff like this to make an “hollow” or bowl-shaped hitbox.

I thought it might be fun for some specific games that like to get creative with hitboxes and how characters can take damage and it saves time having to do a bunch of math to see in what your proximity and position is relative to the shapecast.

16 Likes

With this new system, couldn’t you just whip up some meshparts or unions of the shapes you want and use those?

I might be misinterpreting how this all works, usually I just let the physics engine do its thing rather than any custom hitbox type stuff.

11 Likes

You technically could but using primitive shapes in usually a lot faster than custom shaped.
Primitive shapes have simple formulas for calculating collision while for meshes it has to check every triangle.

Using a ball or a cube is a lot cheaper and faster performance wise in general.

13 Likes