Prevent Players from pushing or repositioning a moving NPC

I saw multiple topics regarding making npcs not collideable when they don’t move but I want my npc to move while players cannot push or push any force towards them.
So the npc moves freely without getting interruped but players can’t walk trough! That’s important.

5 Likes

I would look into Collision Groups. With this you can make it so the NPC can collide with everything BUT other players/characters throughout the game. https://developer.roblox.com/en-us/articles/Collision-Filtering

2 Likes

And the players could still collide with the npc but would apply any force?

1 Like

Try setting the CustomPhysicalProperties.Density property of the HumanoidRootPart to a relatively high number (maybe 2?). I haven’t experimented much with elasticity but I’m pretty sure you can also set the Friction of the body parts to 1 and the FrictionWeight to 100.

1 Like

I tried setting the density to a 100 and it didnt do anything.
I am developing a Attack on titan game and titans are huge.
While im hooked to the titan he freaks out and gets pushed in the sky etc.

1 Like

Tried messing with the Mass of the NPC’s root part?

3 Likes

You will have to interpolate the position instead of relying on humanoid’s physics. Humanoids are extremely old and were made for “Robloxian” characters and not something that would overpower anything in physics as that has to be often written as an exception.

1 Like

You should probably use collision groups and set all the parts not to collide with the character, and then one big part that can only collide with characters as a hitbox so they cant go through them. Definitely should mess with density though.

3 Likes

Interpolate the position?
So are u suggestion to make my own humanoids?

1 Like

Not exactly. Only handle the movement through a custom implementation, humanoids are adequate for the rest.

Though @RVVZ 's solution will also work if you move the hitbox with a constraint to avoid it affecting the real character.

1 Like

wait, I can’t remember but if settings collision groups to false does that mean .Touched isn’t fired? If so that could mess up their code if the use it.

1 Like

Then they could just connect it to the hitbox’s Touched event.

2 Likes

This didnt work. I tried it again and nope don’t work

1 Like

AoT is epic so its cool you are making a game on it.

I don’t believe merely setting the humanoid root part’s density is going to be enough. It will definitely have an effect on the entire model’s stationary space but the players mass and inertia will still be able to interact if you hook onto the titan.

Instead, @Paintertable , I suggest that when the player itself hooks onto a titan, you set all of the player’s parts massless property to true and toggle it on when your hooked on, and off when you aren’t. What you described was that the titan gets pushed around when the player is hooked onto it, so this should nullify the potential force being exerted by the player, thus the titan shouldn’t glitch out.

1 Like

Interesting idea, I’ll definitly try that out later when I am home and come back to you! :))

2 Likes

It is super weird…
It still didnt work and I don’t know why. I am so frustrated.
I can later post videos on what is excacly happening.

I really want this fixed.

1 Like

It would be very useful to know how you are managing the actual attaching of the player to the titan. If you can provide a video then that’d be very useful.

Hope we can fix this.

1 Like

Alright. Basicly Im raycasting the point where my mouse is, if it is in range, it will create a small part , invisible and basicly I’ll push the player with some force towards that point.
I can provide you with gifs or we could even test the place together


if you look closely, I have put my mouse on the area where the little part is and you can even see it if you look closely.

The Part is not collideable

1 Like

I can open up the place so we can test it if someone likes :))

1 Like

You said RVVZ’s solution didn’t work, but you probably misunderstood what we meant.

  • Set the collision group for all of the NPC’s parts to something else (2, 3, whatever) and make the 2 groups ignore each other.
  • Make a part (from now on referred to as the hitbox) that is roughly the size of the NPC (but doesn’t mess with its attacks).
  • Create an AlignOrientation and an AlignPosition constraint and set the Attachment0 to be the hitbox (or a constraint in the hitbox, IDK if we can just assign BaseParts) and the Attachment1 to be the NPC’s HumanoidRootPart.
  • Finally, parent the constraints to be the hitbox’s descendants.

This way, the player’s character can only affect the hitbox, but not the NPC’s character. This is also why you should NOT use WeldConstraints, Welds or Motor6Ds for this as that will make the hitbox part of the rig, transmitting the forces onto the NPC.

Essentially, the point of this is to make an intermediary hitbox part that will filter what can affect what when it comes to forces.

11 Likes