I’m trying to create a hitbox visual for characters. The hitbox should follow the character’s HumanoidRootPart and maintain a specific orientation. (0, 0, 90)
The problem is the character keeps flipping around and the orientation goes back to the default (0, 0, 0)
Video of what’s currently happening:
What I want:
I’m using RigidConstraints and Attachments to do this.
Code:
local rig = workspace.Rig
local humanoidRootPart = rig.HumanoidRootPart
local baseAttachment = humanoidRootPart.BaseAttachment
local function createHitbox(radius)
local hitbox = Instance.new("Part")
hitbox.Shape = Enum.PartType.Cylinder
hitbox.Size = Vector3.new(1, radius, radius)
hitbox.CFrame = CFrame.new(baseAttachment.WorldPosition)
hitbox.Orientation = Vector3.new(0, 0, 90)
hitbox.Color = Color3.fromRGB(200, 0, 0)
hitbox.Transparency = 0.5
hitbox.CanCollide = false
hitbox.Material = Enum.Material.Neon
local hitboxAttachment = Instance.new("Attachment", hitbox)
local rigidConstraint = Instance.new("RigidConstraint", humanoidRootPart)
rigidConstraint.Attachment0 = humanoidRootPart.BaseAttachment
rigidConstraint.Attachment1 = hitboxAttachment
hitbox.Parent = rig
end
createHitbox(32)
1 Like
I’ve gotten closer to what I want but it wobbles now.
local rig = workspace.Rig
local humanoidRootPart = rig.HumanoidRootPart
local baseAttachment = humanoidRootPart.BaseAttachment
local function createHitbox(radius)
local hitbox = Instance.new("Part")
hitbox.CanCollide = false
hitbox.Size = Vector3.new(1, radius, radius)
hitbox.Shape = Enum.PartType.Cylinder
hitbox.Color = Color3.fromRGB(200, 0, 0)
hitbox.Transparency = 0.5
hitbox.Material = Enum.Material.Neon
local hitboxAttachment = Instance.new("Attachment", hitbox)
hitboxAttachment.CFrame = CFrame.Angles(0, 0, math.rad(90))
local rigidConstraint = Instance.new("RigidConstraint", humanoidRootPart)
rigidConstraint.Attachment0 = humanoidRootPart.BaseAttachment
rigidConstraint.Attachment1 = hitboxAttachment
hitbox.Parent = rig
end
createHitbox(32)
Frostholl
(Frost)
January 27, 2024, 1:16pm
#3
make the hitbox part massless by doing
hitbox.Massless = true
also use welds instead since they’re actually suited for this
local weld = Instance.new("Weld")
weld.Part0 = humanoidRootPart
weld.Part1 = hitbox
weld.C0 = CFrame.Angles(0, 0, math.rad(90))
weld.Parent = hitbox
Frost:
hitbox.Massless = true
Thank you, making it massless worked even with RigidConstraints.
local rig = workspace.Rig
local humanoidRootPart = rig.HumanoidRootPart
local baseAttachment = humanoidRootPart.BaseAttachment
local function createHitbox(radius)
local hitbox = Instance.new("Part")
hitbox.CanCollide = false
hitbox.Massless = true
hitbox.Size = Vector3.new(1, radius, radius)
hitbox.Shape = Enum.PartType.Cylinder
hitbox.Color = Color3.fromRGB(200, 0, 0)
hitbox.Transparency = 0.5
hitbox.Material = Enum.Material.Neon
local hitboxAttachment = Instance.new("Attachment", hitbox)
hitboxAttachment.CFrame = CFrame.Angles(0, 0, math.rad(90))
local rigidConstraint = Instance.new("RigidConstraint", humanoidRootPart)
rigidConstraint.Attachment0 = humanoidRootPart.BaseAttachment
rigidConstraint.Attachment1 = hitboxAttachment
hitbox.Parent = rig
end
createHitbox(32)
system
(system)
Closed
February 10, 2024, 1:17pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.