Introducing generalized shapecasts

This seems pretty useful.

However do you know then we’ll eventually be getting margins? After all, it was you guys said you were going to add margins in the first place. You also said it would be parallel with Shapecast, We’re still hearing that margins are on their way. So, any idea when they might actually arrive?

14 Likes

Can you give us some insights on when that’s exactly coming? A lot of us are curious.

11 Likes

Still would be convenient to have it as a official feature imo.

9 Likes

this may sound stupid, but i feel like shapecasts should give multiple hit results, like returning every part that is in the way of the shapecast instead of stopping at the first hit, is there a way to do that or do i have to create multiple shapecasts?

20 Likes

THIS. I want to use shapecasts as a far better version of how I previously did NPC viewcones. But, them only detecting one object makes this almost impossible.

13 Likes

With that said, a chronological array of what object was hit first with all the following ones.
That would be an honest blessing.

14 Likes

Why not repeat shapecast with blacklisting previous parts?

11 Likes

The issue would be this, so I want the zombie to detect if he can see the player. With this fence, we would automatically assume the zombie isn’t seeing the player.

Now with this Instance, the player can actually be seen but Raycast stops at the first thing it hits:

If this is a Union/Mesh or anything else, is hard to know when to determine if it should ignore the object or not. Right now the only thing I can do is tag every object, so it is ignored by the Raycast, which is very tedious.

This is what I want it to do, it would be a very different type of Raycast indeed, but it can also be useful to determine if a point is safe to walk up to when there is a bit of something dangerous around a part that you want to detect.

Here is the image with the path, we want to know if there is no lava around, yet it touched the tip of the terrain and now it says is safe…

I cannot just ignore Terrain there, as the terrain can be covering lava and be considered safe.


If there is a better way of doing this, can you let me know? (Do not focus on these examples only, imagine a whole game with a lot of details with broken walls, tiny holes here and there, meshes that allow you see through them, in short, many types of objects all around with geometry that still allows you see through like a fence).

9 Likes

Don’t forgot about regular RayCasts. They will perfectly solve your problem with zombee and fence. Yes, it may have flaws, but it will solve them if you TRY to fix them.
About lava:
I don’t really understand what you wanted to tell there. You need detect if there’s lava nearby? And what lava is - terrain material, part or smth else?

5 Likes

Awesome Update. But where is the New UI update. I am really excited to use it since i am done with this UI.

6 Likes

I know but is like the old way of shooting like 40 Raycast to check if a player is there.


About the lava, it could be fixed doing tons of regular Raycasts as well. I just wanted to know if lava could be possibly reached accidentally by the NPC to avoid that area.

Anyways, that’s why the people above asked for a way to let the cast to continue and grab all the possible parts. But anyways…


Cuz the shape casting, seems really good until you see it hits a tiny, really tiny edge and that’s how it goes to waste. (Depends on the use-case of course)

5 Likes

But raycasts are still more efficent and less time consuming than shapecasts (x3).
local start = os.clock() for i = 1, 10000, 1 do workspace:Spherecast(Vector3.zero, 5, Vector3.xAxis * 1024) end print(os.clock() - start)
Sphere cast 10000 times consumes 1.6 seconds
local start = os.clock() for i = 1, 10000, 1 do workspace:Raycast(Vector3.zero, Vector3.xAxis * 200) end print(os.clock() - start)
I expected diffirent result, but this took 0.55 seconds
Strange result btw, increasing LENGTH of ray/shapecast will increase processing duration for both.

I don’t expected shapecasts be so better than I thought.

About lava - if you don’t want to allow NPC go into it, just use weighted pathfinding? Or if you need just value if there’s any lava nearby use GetPartsInRadius() or how it called.

6 Likes

Awesome update.
One thing that would be nice if it were clarified - does the accuracy of a shapecast change with a mesh’s CollisionFidelity? If so, would that mean that Box or Default would be more performant than Precise?

4 Likes

Remember that raycasts are a simple 1-dimensional beam whereas shapecasts are 3-dimensional. A difference of about 3x speed between the two seems understandable.

You should use codeblocks when posting code snippets. There’s a nice guide for formatting posts here

3 Likes

I not expected shapecasts to be only 3x slower. I expected them to be much more slow, bc of collsions checking?..

Also, I typed codeblocks like this because code was typed in command line and meant to be pasted into it too. Codeblock will make “scrollbar” which are not very comfortable with long strings.

5 Likes

For your fence problem, I suggest that you create a collision group for all BaseParts that you want your zombies to be able to see through. You can then use this collision group in a RaycastParams and blacklist the collision group you made, and you can use the RaycastParams in your raycasts.

7 Likes

For decades, cats have chased laser beams. Now they can BECOME the laser!

7 Likes

Is there any plans for an specialized and perfect “CapsuleCast”?. Sure you could kind of make a capsule cast with a couple shapes, or maybe with a capsule mesh, but it would be great to have a special Capsule shape. Most engines like unity/godot/unreal has an specialized CapsuleCast casting, it’s used a lot on kinematic movements

13 Likes

that’s cool and all. but when will animation stuff get fixed so the “Sanitized ID” error doesn’t show for every animation anymore and a lot of toolbox models using animations get fixed?

7 Likes

Would using the spherecasting or using the cylinder base part using the new method be better for performance?

3 Likes