I want to make the head just look up and here is some code to do that;
head.CFrame = CFrame.new(head.CFrame.p - Vector3.new(0.4, 0, 0)) * CFrame.Angles(math.rad(45), 0, 0)
but it doesn’t give the exact outcome I wanted;
I want to make the head just look up and here is some code to do that;
head.CFrame = CFrame.new(head.CFrame.p - Vector3.new(0.4, 0, 0)) * CFrame.Angles(math.rad(45), 0, 0)
but it doesn’t give the exact outcome I wanted;
Change the orientation and not the position
I think you change the Motor6D of the rig.
Edit:
Actually, Motor6Ds are used for animations. Basically, the Motor6D acts like a weld, but then it has a few more properties that are changed by an Animator/AnimationControler.
Changing the Orientation of the head changes the “weld” part of the Motor6D. This is an easy and efficient way to do it, but then you don’t know where the head was originally and it might be hard to move the head back.
Using an animation/animator changes the Transform property of the Motor6D. You can also do this manually with a CFrame.
The
Transform
property determines the offset between these parts. This can be set manually usingRunService.Stepped
or through anAnimator
.
You can read more about that here:
Just make a clone of the real head, remove components of type like a Motor6D and make the other head invisible
Yeah but this would result in other problems like the head not actually staying on the rig.
I actually use CFrame so I doubt this will make a difference
Wouldn’t this remove the head from staying on place it would just fall off.
Tty disable the Neck(Motor6D) inside the player Torso.
As I said this would disconnect the head from staying on the players body.
How about create a fake head and make the original one invisible. Attach the fake head to the torso using a constraint or using any methods.
head.Orientation = Vector3.new(head.Orientation.X, 180, head.Orienation.Z)
Fairly simple (this will flip the head upside down).
Okay yea no changing the CFrame of the part itself won’t do anything except mess things up…
You have to change the C1 (cframe) property of the Neck object that’s connecting the head to the torso.
You can find the neck parented to the torso.
Now your method sorta works my code in in runStepped so I have to find a way to make it only run once.
What do you mean by CFrame property of neck
?
local headRotate = false
--inside renderstepped code
if not headRotate then
headRotate = true
head.Orientation = Vector3.new(head.Orientation.X, 180, head.Orienation.Z)
end
--sometime later if needed
headRotate = false
You could also make “headRotate” a “BoolValue” instance as well.
Yeah but that feels sloppy hopefully I can find a work around.
Any action inside of RenderStepped will be ran every frame so just try to execute the code (which only needs to be ran once) somewhere suitable outside of RenderStepped.
Actually the work around and better way to do this is with an animation because I do use custom animations and they would make it look weird. This would overwrite the animations and achieve the same effect.
You guys really don’t like Motor6D, here is my script:
local Player = game.Players.LocalPlayer
local Character = script.Parent
local Mouse = Player:GetMouse()
local Torso = Character:WaitForChild("Torso")
local HRP = Character:WaitForChild("HumanoidRootPart")
local Neck = Torso:WaitForChild("Neck")
local Neck_C0 = Neck.C0
game:GetService("RunService").RenderStepped:Connect(function()
local theta = math.asin(((Mouse.Hit.p-(HRP.Position+Vector3.new(0,HRP.Size.Y/2,0)))).unit.Y)
Neck.C0 = Neck_C0*CFrame.Angles(-theta,0,0)
end)
I placed the script inside StarterCharacterScripts.
What actually happening here is that I take a vector from the head original position which is HRP.Position+Vector3.new(0,HRP.Size.Y/2,0)
to the mouse position Mouse.Hit.p
and then make it 1 stud length with .unit
As we know from the math classes: We know that we can make the point with cos and sin Vector2.new(math.cos(theta),math.sin(theta)
, if we do so, our vector length is 1.
So we just convert out Y from sin to asin, regular angle.