NPC momentarily stunned after deleting weld; won’t walk

Hello,

In my game I have customers who can lie on beds / sofas in their rented apartment.

In order to create the effect of a player sleeping / sitting down, I weld them to an invisible part and then play an animation. In this case, the invisible part is just above the bed so that they are animated to look to be lying / sitting on the bed

This solution is great, however, there is a problem when I delete the weld and stop the animation. My script then tries to move the NPC using pathfinding, however, just after the weld is deleted / animation stopped, the player gets stunned and won’t be able to move. Sometimes the NPC will just fall flat on its face, and take a few seconds to get back up again. By which time the pathfinding script’s ‘path block detector’ figures that it can’t move the NPC, so it destroys itself.

GIF example of it NOT working:

What it SHOULD be doing (and sometimes does):

You can see in the top GIF that the player gets stunned, no movement animations play, and almost falls over. But in the bottom GIF, it works perfectly and the player just walks away from the bed. That is the intended behaviour. Sometimes it will work, sometimes not. Could be due to player sizing etc, but still, not a true solution really.

I think that it is because due to the bed being anchored, as when the weld gets deleted and the animation stopped the player’s body might collide with the bed. Obviously I don’t really want to unanchor the beds, which is why I’ve come here to see if there are any other solutions.

Am I doing this wrong from the start by welding the player to a part? Is there a way to stop the player from being stunned once the weld is destroyed and animation stopped?

20 Likes

So what you can try to do is moving the npc a bit up after you unweld it. Setting his root position a bit up should cancel that effect. Or anchor the root for like 0.1/0.5 seconds.

1 Like

Move the NPC to the side of the bed when you unweld them. I assume pathfinding can’t find a path sometimes due to the bed which is why it’s inconsistent.

You can also try making the NPC walk to the exit directly using Humanoid:MoveTo() without using pathfinding to pinpoint if it’s a problem with humanoids/the welds or your pathfinding script.

Would it not make more sense to anchor the HumanoidRootPart and then CFrame it? I feel like welds are unnecessarily here and are probably causing your problem.

So you can try moving the root up before unanchoring it, that stun effect is caused by the collision of the root with the bed.

That is also something I have tried but the NPC will still fall over afterwards, even when you teleport the player to a location above the bed as @jcnruad900 said so they do not collide with it.
1p2m1FU9Af

Is the NPC PlatformStanding? Try disabling PlatformStand, maybe.

PlatformStand is always disabled.

3 Likes

Can u try set the root part to a color and do a video to it while it wakes up from the bed? Also how many times it wakes up in the right way and how many times it doesn’t wake up in the right way.

PS: I set HRP CFrame to be above bed for 2 seconds before unanchoring.

rO2N88RrYG

1 Like

I think it has something to do with how the npc lands when the weld is destroyed.

Even when CFraming / Anchoring NPC without welds, still happens.

3 Likes

Oh, I think it gets stunned due to the inclined root, a time I messed up with my character root, inclining it or it got stunned or it stood up istantly. Infact in the video the root is inclined.

1 Like

This looks a lot like platform standing to me. Platform standing disables humanoid physics, which looks like what’s happening where. Are you 100% it never changes?

Watched it the entire time and it never changed, was always unchecked

3 Likes

Could you provide a step by step list of everything that happens when the NPC both lies down and gets up? Might give a clue what’s happening.

You may try set the vertical orientation(using cframe) to 0, it should prevent the humanoid from getting stunned. Also it’s not platform standing because in platform standing legs would collide with the bed.

2 Likes

What is the humanoid state every frame when it gets up?

Instead of using an invisible part and welding it , you could use seats to make it non-buggy and much more simple , you can force a certain animation on the NPC while it is seated , and when it’s done playing just do

workspace.NPC.Humanoid.Jump =  true 

Which will cause the weld to automatically break without causing any problems to the NPC , while also providing a smooth animation between sitting and getting up

3 Likes

My game is R15 only, happens with most