Collision Service

Basically, a service that provides easily accessible functions that allow us to check for collision on the “3d lvl.”

Function to check collision might go like this:

CollisionService.checkBlockCollision(Part,ListOfPartsOrASinglePart)

or

CollisionService.checkBlockCollision({Size,CFrame},ListOfSizesAndCFramesOrParts) 

In the future, listofparts could be a collision layer, when roblox adds that. Or could be tags, again, when it is added.

Types of collisions detections that can be made:

Block, Sphere, Cylinder, Pyramid, Unions, Mesh, etc.

Note: I know that you can currently do something like Part:GetConnectingParts() or Part.Hit, but I don’t think those fire if you cframe them.

3 Likes

Have you tried playing around with this?

http://wiki.roblox.com/index.php?title=API:Class/BasePart/GetTouchingParts
(not the same as GetConnectedParts)

It works fine for anchored parts that are being cframed too, you can implement the whitelist stuff on top of it yourself

1 Like

Yes, but sadly those parts have to exist before I can call such a method. And I can’t really control what it’s checking.

1 Like

It’s relatively cheap to instance a part to check for collisions this way just for a split second (you don’t have to wait a frame before you can call GetTouchingParts). Not sure how many times a service where you can specify a hitbox without a part actually being there would be used. Can you explain your use case with a more detailed example?

I wanted to do “theoretical” checks on the server without having to make a part. And I’ve heard it’s not cheap to make a part. But if it was cheap, I only want the server to make the part. But if I do, the client will also make the part.

EDIT: But you’re probably right. GetTouchingParts should do the job. It slipped my mind that they are able to do anchored checks.

To be honest ROBLOX should really consider better solutions like what Unity offers in its Physics Lib and is similar to what you suggested
https://docs.unity3d.com/ScriptReference/Physics.html

2 Likes

I’m doing collision checks in Lua for the house editor I’m working on. The math gets pretty intense but it’s worth the extra control

1 Like

Is it a grid based system? If it is, you can use 2d collision checks on the base of the object, unless your house editor is more advance than I’m imaging it rn. :stuck_out_tongue:

No it does cuboid intersection, raycasting, and wall cutting in Lua

https://devforum.roblox.com/uploads/default/original/3X/0/3/037796063f223cd7fd9136ffdce59b583695f0e7.gif

https://devforum.roblox.com/uploads/default/original/3X/e/1/e151d80ca9f8e99afa8311cd2a16c89bae705b32.gif

6 Likes

Dang, that’s so cool. The browser crashed 6 times on me while I was trying to post this because it’s too amazing for my pc to handle. xD

I’d suggest using this: http://devforum.roblox.com/t/3d-collision-detection/13697/13

Use cases for this typically involve frequent usage, so performance would be substantially better using an API built in C++ rather than a user module implemented in Lua.

Yes, but for the mean while, you can use this. Better than nothing and that module is very efficient.

2 Likes