Really good update. I love it!
This is a great addition!
One question though, is there any notable performance difference between Blockcast and Spherecast?
I’ve been testing shapecasts and while they are significantly more accurate than its raycast counterpart this one issue is holding me from fully adding them. If this were looked into then I would implement Blockcasting to my game.
This is a fast combined GJK / Conservative Advancement loop.
WorldRoot:Shapecast(supportFunction)
We probably won’t add user-defind support mappings; I’ll explain why:
The gory details
Speed
Support mappings are evaluated many times for every shapecast, so “how fast is my support” is important. We solve this right now with hardware-specific intrinsics and estimates, and we have specialized fast support functions for even polyhedral shapes like Wedges and CornerWedges.
Lua support functions don’t get that benefit. There is also the extra overhead of Lua/C++ back-and-forth.
Ease of use
Raw support functions aren’t user-friendly. It’s easy to write a support function that “looks right” from most angles, but fails to actually be a valid convex support. If you accidentally don’t write a function where the result is the maximum of dot(direction, vertex) for some convex for every possible angle, you don’t just get a weird shape - the cast interpenetrates into numerically invalid nothingness.
Then there are sandboxing concerns: The support function can’t be allowed to modify the DataModel because that risks putting broadphase out of sync. Allowing it to modify the world means resynchronizing broadphase every step, which is impractically slow.
Meanwhile, the value is limited by the fact that support mappings can only express convex shapes.
What we can do
We’re way more likely to add more native part shape types, like Ball/Cylinder/Wedge. These would be broadly useful beyond shapecasts, and incidentally make shapecasts more powerful.
Let us know if you have any shapes in mind (preferably in a dedicated thread!)
Yeah, ViewportPointToRay is clumsy, especially because you have to remember whether you’re in viewport or screen space. It might be nice to get a world origin and direction from an InputObject or another shorthand. We’ll think about it.
Have u ever heard about the Dot product?
you know i think i could think of a use of this if it is feasibly even possible with Roblox in its current state. and that thing would be mirrors like for example. the one most bathroom have in front of the sink or on the side of cars but even if it is feasible to do this in Realtime without having to do some funky stuff with view ports because you can’t exactly use more than one camera at a time per player and so I’m Shure it would be a programming and graphics nightmare.
Is there going to be a cone cast added as well or some way to change the shape / size of the beginning and end shapes?
everytime im tryna learn scripting, new features keep coming in…
exciting.
Wow! This is going to work just fine. I love it!
Amazing, A needed update, Gonna make combat in most games wayyy easier.
This is literally already possible
I had no idea that this implementation of shapecasts was possible. I wonder how easy it is to implement with something like this though.
I am not talking about conecasts. I was talking able being able to detect parts in a cone shape.
It seems as if I had mistakenly replied to the wrong person my bad.
Anyways the code is pretty simple
local function IsPartInCone(conePeak: Vector3, coneDirection: Vector3, point: Vector3) -- Cone CFrame from peak looking into cone
local CONE_RADIUS = 32
local CONE_HEIGHT = 64
local Angle = math.atan2(CONE_RADIUS,CONE_HEIGHT)
local ConeDirection = coneDirection.Unit
local PointDirection = (point - conePeak).Unit
return Angle < PointDirection:Dot(ConeDirection)
end
This literally took like 5 minutes to write.
I have a very game-breaking issue with shape casts, they crash the game! On both studio and game client (I can’t pinpoint a way to replicate it) but once the heartbeat loop is activated that creates a shape cast around a bounding box of a model in the direction of the velocity’s unit, the game crashes, and Roblox gives the error message something along the lines of ‘oops sorry we have to quit… etc’, No errors in the output, it just crashes, I can’t seem to “replicate” this issue easily so if someone familiar with shape casts wants to take a look I can add you to the team create.
Note I’m 100% sure its because of shape casts.
code as example:
function Update_Hit_Scan()
local Folder = Detection_Data.DetectionFolder
local boundingbox, Size = Current_Hit_Model:GetBoundingBox()
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Whitelist
Params.FilterDescendantsInstances = Folder
local Cast = workspace:Blockcast(boundingbox, Size, Vector3.new(1,0,0), Params)
if Cast then
print("hello")
Runs every heartbeat
Just curious, but why continuous collision? lol That sounds like the .Touched
event, which is notorious for being unreliable. For a second I thought they finaly gave us an improved .Touched event is there any plan for it? Or is using RunService while casting rays\shapecasts still the only way to go?
Still, amazing update! <3
Are you sure the unit velocity of the part is not NaN
? Also why are you creating new params each heartbeat?
good question lol, even if it was NaN, it shouldn’t crash roblox.
I’ve always had issue using ray cast effectively , because i mainly making fighting games. and it doesn’t do very well for detection for aoe’s or just hitboxes that arent a straight-line. so i use it sparingly. and i’m not to sure about the workarounds people have made to make raycast more practical. but this shape cast is what i’ve needed and wanted for years on this platform. region3 fell short for what this can do.