Today we’re releasing generalized shapecasts. These allow you to cast any arbitrary part into the world: Blocks, spheres, cylinders, wedges, CSG, MeshParts, etc.
We previously released
Spherecast as ways to find collisions using swept shapes. These can be thought of as “raycasts with volume”.
Until today, shapecasts were limited to block and sphere shapes, which limited their usefulness. Even if you started with a block or sphere-shaped part, you couldn’t simply plug the part into the shapecast query; you had to manually copy over the CFrame/Size values.
For performance reasons, you can’t cast terrain, i.e. use Terrain as the part argument in Shapecast.
- Draggers: To create a furniture dragger, you previously had to cast many rays and do a bunch of math. Casting the mesh directly simplifies this and results in more accurate collisions.
- Projectiles: To simulate a rocket’s collisions, you previously had to approximate the rocket shape with block/sphere/raycasts. You can now accurately cast the rocket directly.
- Mesh collisions: Developers could previously only use approximations for other objects such as swords and car colliders. Casting meshes allows more accurate collisions with less code.
|The part to cast.
|The direction in which the part is cast. Direction.Magnitude is the maximum distance the part will travel to find a hit.
|RaycastParams struct for defining filters.
Usage is congruent to the existing shapecast methods, but we now take a part instead of a shape / cframe / size.
Performance is acceptable for smaller cast sizes, but large casts against dense worlds can be pretty slow. We plan to optimize this with our ongoing broadphase work.
A common pain point with shapecasts is that there is no collision margin (aka “skin”). This means that a shapecast starting flush with another part won’t detect that part. We’ve heard your feedback, and this is one of the next steps we will be taking for shapecasts.
We’ll be adding an optional “cframe” param to override the part’s original CFrame later this year.
Thank you for your feedback so far! Let us know what you think and if you have any questions below.