I am currently working on a project which utilizes a grid-based placement system. At the time of writing this, it is possible to overlap as many objects as the player desires. This is obviously an undesired feature of the system. My question is, how can I use something like the touched event to detect colissions between baseparts? As mentioned on the Roblox Dev Hub, the touched event only fires when parts physically collide with each other, and not when their positions or CFrames are being manually modified.
Let me know if you have any suggestions!
Thank you in advance.
From my past experience, using the Touched and TouchEnded events for stuff like this is a complete pain. Consider using WorldRoot:GetPartsInPart() or since you’re implementing a grid placement system, use WorldRoot:GetPartBoundsInBox() which would be more efficient since you’re dealing with cubes.
Maybe I didn’t read far enough, but when using the workspace:ArePartsTouchingOthers() method, is there a way to get a table containing all of the parts that are coming in contact with the parts in the partList table?
You can yes if you make a table that contains all the parts that you wish to ignore. You can simply make a if statement that checks if that part isn’t in that ignore table it will check if it’s colliding.
for _, part in pairs(partList) do
local touching = game.Workspace:GetPartsInPart(part)
for _, v in pairs(touching) do
if --v isnt in the ignore list then
-- Return or anything you want to happen to that touching part.
This is working great! Just one more question. With the PartsInPart() method, is there a way to customize the overlap? For example, I have a wall object and I need to be able to place two walls directly next to each other, (touching), and it considers them to be colliding with each other.
You could make a dictionary that says what part is considered a wall and then do a if statement checking if it is a wall and touching then make another if statement checking how far the wall is inside the other wall.
that’s where things get a little complicated because you are checking if two a 3D parts are overlapping.
Sadly this would take time for me to make a example script. So here’s a similar question someone asked that you are looking for.