Introducing Shapecasts

It would be extremely helpful to be able to visualise raycasts just like in Unreal Engine. Whether this is by a RaycastParam or a checkable setting in studio settings (like geometrydecomp).

I do this currently by creating parts to visualise them, but it’s time consuming and doesn’t show intersection points unless you also program those in to test.

18 Likes

Might I recommend the recently added WireframeHandleAdornment?

2 Likes

It still requires me to write more code to debug my raycasting to make sure I have set up the maths right and see if it should be hitting objects, when I say visualise I mean purely for debug purposes, so only visible in studio and for it to be convenient and quick to activate!

Yeah, not a substitute for some kind of built in visualization. Just saw an opportunity to spread the word about WireframeHandleAdornment since it’s a relatively new and quite powerful addition for any kind of custom debug visualization.

7 Likes

So this only returns a single instsnce when the shape intersects with multiple objects?

The shapecast will never intersect multiple objects, since it only proceeds up to the point of the first touch.

It may exactly touch multiple objects, and in that case you’ll get a seemingly random one of those objects depending on how they happen to have been ordered in the engine’s internal data structures.

7 Likes

OK that clears things up for me and now i know what im able to use this for. Thank you.

I’ve tried using WireframeHandleAdornment but I am not getting any results. There is no information on the documentation page so I am wondering how you set them up.

Edit: Just figured out that they are not currently accessible to the public.

accidental reply whoops

There’s no way I can use Blockcasting without having to resort to making extra raycasts due to the lack of margin space.

Please, Roblos. marjin :pleading_face:

1 Like

Are shapecasts intended to be deterministic? I seem to be getting inconsistent normals for the same inputs.

Using the same position, radius, direction and params casting into an anchored part. The two shapecasts returning different normals are across the server / client boundary if that changes anything.

If shapecast can only detect the one and only object it first touches, then how can this be used for area of effect damages??

2 Likes

bro… just check distance and then use something like this for the cone check.

function isFacing(cf, pos, angle) -- checks if pos is within the cone/angle of cf's facing direction
	return math.acos(cf.lookVector:Dot((cf.p + pos).unit)) < angle or 120
end

i can’t think of a reason to ever shapecast a cone, this is certainly not one of its usage cases

That doesn’t account for precise collisions or even bounding boxes.
Conecasts would be perfect for precise collision checking which is one of the main purposes for ray and shape casts.

1 Like

Use cases for Cone casts could be for certain ranged projectiles, shotguns / blunderbusses, directional shockwaves, or directional cast ability seen in topdown MOBAs.

They would be especially useful if casts could return a list of intersected instances.

2 Likes

I’m super excited for this, I really wanted to use something like this for the longest time so I could implement a fully custom character controller / collider with custom physics.
I hope there’s support in the future for (at the least) cylinders, and I really would love to see a CapsuleCast in the future since I think a lot of people will use something like this for capsule collider collision detection (two spheres jointly connected by a cylinder / aka pill shaped).

Rejoicing in the fact that I may not have to learn and implement some very involved mathematics for calculating collision.

Props to those like AxisAngles who have managed to do stuff like this using pure math in lua - I hope this is much faster if it’s inbuilt if its made using C?

Awesome stuff anyway. Very happy with this.

I really think Capsule shape would be the most desired, especially for custom character controllers. Similar to a sphere cast but with an additional parameter a alongside the radius:


(with a cframe to specify orientation alongside position)

@preacher_online If you were to cast a capsule shape forward it would not produce a pill shape cast, it would appear like a parallelogram with rounded corners in 3d.


Like this, but in 3D :grin:

@mantorok4866 You can manually do this by doing multiple small raycasts each frame

7 Likes

ETA on the margins/tolerances?

7 Likes

This! Margins/tolerance is extremely important for shapecasts!

2 Likes

Very cool. I can see a lot of uses for this.

1 Like

Thats gotta be the most epic update this year :exploding_head: i was struggling with custom shapecasting for waaay too long but this update just fixed every single problem i had. Thank you so much :pray: