Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to make NPCs not collide with each other? (Unsolved)

Asked by
RoboFrog 400 Moderation Voter
10 years ago

As of now, I'm making a game where NPC's will have to only take one path, and I need for them to be able to walk through each other. I have already solved the following issues --

  • I put a BodyGyro and BodyPosition to keep them in place, while the floor is CanCollide = false.
  • All of the NPC's body parts are CanCollide = false

An issue came up to where whenever the NPC moved (for instance, with manually setting the MoveTo property of Humanoid), the Torso and Head would become CanCollide = true. To solve this, I put the following script into the head (it's inefficient, but it was for the sake of testing) --

while true do
    script.Parent.CanCollide = false
    script.Parent.Parent.Torso.CanCollide = false
    wait()
end

This did work, making the torso and head always stay CanCollide = false. However, it still didn't work. Whenever I make an NPC MoveTo a position behind the other (which was a complete duplicate), it will still get caught on the other NPC about 95% of the time.

Whenever the NPC is moving, I can see the CanCollide property flash extremely quickly (as I would expect). Does this mean a shorter wait time would rectify the situation?

Or, is there another way to solve this issue (or another way to deal with NPC collision)?

Thanks for reading, and I hope to find out a bit more on this strange issue.

1
Try using game:GetService("RunService").RenderStepped:wait() for the wait. Make sure it's a local script. Spongocardo 1991 — 10y
0
Sadly, that's not working out. Since this isn't a player-run character, local scripts aren't running correctly. RoboFrog 400 — 10y

1 answer

Log in to vote
0
Answered by
Elttob 15
10 years ago

Use the Changed event of the Head and torso and set the CanCollide to false in there. Voila.

0
I'd have bet money that this would have worked, but sadly, it's still not changing things fast enough. I'm only using the Changed event, without any waits. RoboFrog 400 — 10y
Ad

Answer this question