I’m currently thinking what should I consider while making NPCs for my own game.
I plan to control a lot of NPCs in real time, with one script.
Most NPCs will use nodes to move from one point to another.
NPCs might stop and do random actions.
NPC will try to recalculate path when it happens to be pushed into an object
I want NPC to face the target.
It actually made me wonder… Should I trust Roblox’s physics (by using humanoid functions) or should I go with CFrame based NPCs still? It’s honestly a hard decision.
I worry about few cases when relying on physics:
NPC gets pushed into an object a bit too hard and gets stuck
Server latency might affect the knockback force.
Server might have too much handle.
It wouldn’t be bad if I would use collision groups, so there’s no risk of being randomly catapulted.
CFrame also does the job nicely. I can even rotate NPCs to face their target. I still need to do something about its interaction with terrain.
IMO physics is always the way to go with moving humanoids. They do come with the issues of character’s getting stuck as you stated but you can use a combination of physics & CFrame to avoid that.
If a NPC can’t get to their target in a reasonable time, you’d assume they are stuck and you can CFrame them to where they should be.
Also I don’t think NPC’s using physics would be expensive compared to CFraming them.
CFrame is the way to go if you can do efficient obstacle/terrain detection.
Roblox’s internal physics replicates physics data to clients so this could be a problem when dealing with 50/100+ unanchored NPCs which could increase ping and ReceivedNetwork stats.
I’m working on a custom NPC system too, a NPC is shown as one transparent part for projectile reasons, it’s also anchored to prevent Roblox from doing unnecessary physics changes on the “hitbox” of the NPC. I’m also going to use CFrame physics to handle movement, which is gonna be tough when it comes to knockback…