我如何找到roblox lua中角色部分的方向?
我正在为我的角色添加腰带,但每当我添加腰带时,无论角色的方向如何,腰带都会朝一个方向。如何使我的人形根部分所面对的方向与腰带所面对的方向相同?A只是一个规则,所有部分都有一个表示它们在三维世界空间中的位置和方向的A。它们都有一个指向其前进方向的LookVector 如果要将腰带添加到角色模型,我建议在模型中使用零件,并使用其CFrame作为起点,然后相应地对其进行偏移 例如:我如何找到roblox lua中角色部分的方向?,lua,roblox,Lua,Roblox,我正在为我的角色添加腰带,但每当我添加腰带时,无论角色的方向如何,腰带都会朝一个方向。如何使我的人形根部分所面对的方向与腰带所面对的方向相同?A只是一个规则,所有部分都有一个表示它们在三维世界空间中的位置和方向的A。它们都有一个指向其前进方向的LookVector 如果要将腰带添加到角色模型,我建议在模型中使用零件,并使用其CFrame作为起点,然后相应地对其进行偏移 例如: -- access the character model in the workspace game.Players.
-- access the character model in the workspace
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
-- DEBUG : wait for player to stop falling
wait(2)
-- choose a starting point
local hips = character:WaitForChild("LowerTorso", 10)
-- create a belt
local belt = Instance.new("Part")
belt.Name = "Belt"
belt.Size = Vector3.new(2,1,2)
-- position the belt on the player's character
-- NOTE - EXPERIMENT WITH CHANGING THESE VALUES TO ADJUST THE POSITION AND ROTATION
local positionOffset = CFrame.new(Vector3.new(0, 0, 0))
local rotationOffset = CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
belt.CFrame = hips.CFrame * positionOffset * rotationOffset
-- weld the belt to the player
local weld = Instance.new("WeldConstraint", belt)
weld.Part0 = belt
weld.Part1 = hips
-- DEBUG : color the front of belt to make sure that it is oriented correctly
local surface = Instance.new("SurfaceGui", belt)
surface.Adornee = belt
surface.Face = Enum.NormalId.Front
local frame = Instance.new("Frame", surface)
frame.Size = UDim2.fromScale(1, 1)
frame.Position = UDim2.fromScale(0, 0)
frame.BackgroundColor3 = Color3.new(0, 0, 1)
-- put the belt into the world
belt.Parent = character
end)
end)