I was working on a script for a two dimensional camera. The character is restricted on the Z axis, so that it cannot away or closer to the camera.
The problem is that my character keeps playing a walking animation, even though it is standing still. My two dimensional camera works fine and my character cannot move on the Z axis. The only issue that I am having is that it does some unwanted animation.
This is the function that is responsible for locking the character’s Z axis:
function lockZAxis()
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(0, 0, math.huge)
bodyPosition.Position = Vector3.new()
bodyPosition.Parent = humanoidRootPart
end
It only makes a BodyPosition that forces the HumanoidRootPart to have a position of zero at the Z axis.