So I’m looking for a way to make an NPC always stand up straight and to never have the NPCs model tilt,
and id like to do this using CFrame but i don’t know how
Can you elaborate a bit? Your explanation isn’t very specific.
Lets say an NPC trips and falls, he would fall down, but if i set the CFrame of the HumanoidRootPart so that it cannot tilt forwards of backwards or sideways, It wouldnt be able to fall down, but that is what i dont know how to do
Try anchoring the NPC’s part’s, especially its HumanoidRootPart, to stop the NPC from moving.
Well you see, i need the NPC to move again andwhen i unanchor the NPC’s HumanoidRootPart, it falls over, and thats the problem
In that case, try setting all the parts’ CanCollide setting to false. Unless you need the NPC’s to do something complicated like Pathfinding or fighting, this should work.
I want it to Fight when i unanchor the HumanoidRootPart so that won’t work
Have you tried using PlatformStand to make the Humanoid stand still?
That usually works for me.
Moreover, I hear that using SetStateEnabled to disable the FallingDown HumanoidStateType can counter this.
A BodyGyro should work for you in this case.
To keep your NPC upright, you would just need to make the BodyGyro
’s CFrame take the character/position’s X and Z position, while still maintain the original character’s orientation to prevent it from tilting.
Ex.
local target = workspace.Target.HumanoidRootPart
local player = game.LocalPlayer.Character.HumanoidRootPart
player.BodyGyro.CFrame = CFrame.new(player.Position, Vector3.new(target.Position.X, player.Position.Y, target.Position.Z))
It should be something around those lines.
That did it!
Thanks a bunch!