Introducing Shapecasts

The minimum size is (0, 0, 0).

3 Likes

A change is already in-flight to fix that code example.

2 Likes

So all parts are detected then? To quote the post:

Except (0,0,0) is impossible, as the minimum is (0.001,0.001,0.001)

1 Like

finally bro :pray::pray::pray: sized raycasts

3 Likes

Absolutely wonderful! I’ve been waiting for this for quite some time. This will serve as an easier and more efficient way to handle splash damage!

Also, are the visualizers built in-house as a beta/Studio setting or was it handmade? Would love to use the visualizers to help debug shapecasts.

3 Likes

Pretty neat feature overall, although I do have a suggestion.

May it be possible to add a parameter in which you can specify an angle to spread the cast like the setting on a surface light instance would do?

1 Like

“* Fast-moving projectiles: Raycasts are fine for small projectiles like bullets, but the movement of larger missiles with volume can’t be accurately modeled with rays.”

a little off topic but would it be possible to add a delay to rays? if we have a projectile system that uses non instant projectiles and we wanted to use raycasting, could we make to where a ray “travels” a distance slowly rather than instantly? this would eliminate the need to make moving hitboxes.

2 Likes

While I would love this as well if it were implemented, I think it’s too non-performant and niche to be implemented

1 Like

Tried seeing the performance difference by directly swapping raycast with spherecast in my parallelized projectile framework
ScreenShot_20230505153931
ScreenShot_20230505153940

Conclusion: no noticeable difference with a spherecast radius of 1, CFraming the projectiles is still the main bottleneck lol

14 Likes

This is very nice, i’ve been trying to get a good way of doing melee hitboxes for a long time, this will serve the purpose perfectly, not only that but really does make it easier to address a lot of other issues that previously had to be handled with normal raycasts, are there plans on supporting other shapes in the foreseeable future?
if so, wouldn’t it be better to have it as

WorldRoot:ShapeCast(
    shape: ShapecastShape
    cf: CFrame,
    size: Vector3,
    direction: Vector3,
    params: RaycastParams?
): RaycastResult?

(shape argument)

instead of separating it in two different functions?

3 Likes

Some shapes are pretty niche and would need their own unique parameters for defining them. Sphere uses radius which is a number, box uses size which is a Vector3, pill would need radius and maybe two extra vectors to define its dimensions and orientation (?)

It would be hard to polymorphize a singleton “Shapecast” function to suit all of them, so I think it would be better to make each type of shapecast its own individual method

4 Likes

are you using bulkMoveTo here?

2 Likes

I was messing around with studio earlier and I saw these methods! You have no idea how excited I was to see this! ^^

2 Likes

Infinitesimally? Really? Didn’t know 0.001 could be called infinitesimal.

3 Likes

The details are in the post that was linked! :slightly_smiling_face:

Being able to raycast in blocks and spheres is already going to provide a huge improvement to our current raycasted hitbox implementation however a full pill shape would enrich the raycasting experience a lot more. Most hit/hurt/collision box implementations off platform are also done as pills.

1 Like

Could you be more specific on your use cases for pill/capsules? The spherecast actually forms a pill/capsule as it “travels”

1 Like

The details, from my use case to shapecasting’s importance to my experience, are in the linked post, I hope that people can read the post over asking redundant information! :slightly_smiling_face:

1 Like

Yeah I did, spherecast forms a pill/capsule so not sure what the purpose of specifically pill would be

The shapecasts, especially how they can be used for CCD, are a major step up in mechanisms requiring raycasting. I’m mainly talking about a fixed pill shape, not an “effective” pill, unless they can truly be used in the same way and not “technically” be used in the same way. The hitboxes of Dark Souls are a great example of this, as I’ve talked about in the linked post. This isn’t pushing a shape, it’s having a fixed shape that I can sweep along a path.

The frame data of Super Smash Bros also provides a reference for all this. The details are in the post and I’d prefer not to repeat, that’s why I linked it. Thanks for your input though, but I’m looking for proper replies only and not so much wanting to spend time on a discussion for this.

5 Likes

Ah, this is more along the lines of conventional CCD rather than roblox’s raycasting, yeah I can’t imagine Roblox would add this anytime soon

What you could do is still use spherecast every frame but make the sphere originate from within the player, as the sword shouldnt be doing damage from behind the hilt anyways. Has the same end result, except obviously if you’re swinging extremely fast it wont detect well. If you run into issues, you could just increase the size of the sphere, or perhaps do more spherecasts between the spherecasts to see if the blade swept thru something and missed it, however suboptimal lol