Methods to detect collsions with moving, unanchored parts

Hi there. I have been making an NPC framework that involves moving anchored NPC models. I noticed that they weren’t colliding with anything and tested it out with a hitbox but that didn’t work. This led me to conclude that moving, anchored parts don’t detect collisions with other anchored parts.

Because of this, I need help making a method for detecting collisions. Please leave suggestions below. Thanks for reading!

While you could dabble with creating your own hitboxes for anchored parts, the loops could prove too computationally expensive if you need to perform them a lot. The most efficient solution might depend on the context behind, and the sort of collisions you need to detect. For example, if all you’re looking to detect is NPC collisions with other NPCs, then if might be better/easier to just implement a system that avoids paths that will cause the NPCs to collide altogether. Lmk some more info and I might be able to offer a more specific solution!

Thanks for your reply. Right now, I am just trying to get the NPCs to collide with parts (other than the player and other NPCs) in the world correctly. Here is what the trouble looks like.

In the beginning, you can see the NPC clipping through the parts a little bit, meaning that there are no collisions. I hope you can show me a method for detecting some collisions! :slight_smile:

To be honest, you best bet is to just fall back on the physics engine that Roblox already provides. It would be more efficient than any system you could implement simulating the same collision detection. (Not to mention it would avoid all the extra work you would be required to do implementing your own system). If you still feel inclined to reinvent the wheel, You could utilize many different combinations of raycasting, calculating magnitude vectors between spherical hitboxes, or CFrame methods for cuboid hitboxes to make a “custom” collision service. Again, this would likely be computationally expensive, especially with multiple NPCs. I’d highly recommend just working with the physics engine Roblox provides for this case.

Thanks for your advice.

The main reason I wanted to make the NPC without Roblox physics is because of some forum posts that said that it would make the NPCs laggy. However, I recently noticed that all of those posts have NPCs that are not like zombies, but like background characters and don’t need to collide as often.