Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Head moving the opposite way in y axis?

Asked by
Hero_ic 502 Moderation Voter
9 years ago

The problem is on my shoulder cam script the arms move down with the cam but the head goes the opposite way I do not know how to fix this any help? please scroll down until you see the problem in the neck.c0.cframe at the bottom of the code

001wait(2)
002 
003local InputService=game:GetService("UserInputService")
004local Camera=game.Workspace.CurrentCamera
005local Player=game.Players.LocalPlayer
006local Character=Player.Character
007local Head=Character.Head
008local Torso=Character.Torso
009local RootPart=Character.HumanoidRootPart
010local RootJoint=RootPart.RootJoint
011local Neck=Torso.Neck
012local RightShoulder = Torso:WaitForChild("Right Shoulder")
013local LeftShoulder = Torso:WaitForChild("Left Shoulder")
014--Camera.FieldOfView=100
015Camera.CameraType="Scriptable"
View all 139 lines...

1 answer

Log in to vote
2
Answered by 9 years ago

Since the arms worked normally and the head was rotating the exact opposite way, the rotation of the head must be inverted in order to get it to rotate correctly.

Copy the value of the CameraOrientation variable and then delete that variable line. Create two variables instead of the CameraOrientation variable, one called CameraHeadOrientation and CameraArmOrientation.

The CameraArmOrientation property should be set to the value of CameraOrientation and the CameraHeadOrientation should be the same, except where the .7 is at near the end of the function call, you want to make it negative.

Making the .7 negative essentially inverts the orientation. The function multiplies the inverse cosine (which is the angle of rotation in radians) calculated in your function by the tween argument, so if you inverse the tween argument and multiply that by the inverse cosine, the inverse cosine angle will essentially be inverted, as opposed to the arm angle.

What you do then is replace CameraOrientation for the neck, right shoulder and left shoulder's C0. CameraHeadOrientation should be the replacement for CameraOrientation in the Neck's C0 and CameraArmOrientation should be the replacement for CameraOrientation in the remaining left and right shoulder C0s.

Your final script will now look like this:

001wait(2)
002 
003local InputService=game:GetService("UserInputService")
004local Camera=game.Workspace.CurrentCamera
005local Player=game.Players.LocalPlayer
006local Character=Player.Character
007local Head=Character.Head
008local Torso=Character.Torso
009local RootPart=Character.HumanoidRootPart
010local RootJoint=RootPart.RootJoint
011local Neck=Torso.Neck
012local RightShoulder = Torso:WaitForChild("Right Shoulder")
013local LeftShoulder = Torso:WaitForChild("Left Shoulder")
014--Camera.FieldOfView=100
015Camera.CameraType="Scriptable"
View all 140 lines...

There may be a more efficient way to do this, but this is what I could come up with that worked for me.

I hope my answer helped you. If it did, be sure to accept it.

0
Thanks so much! Hero_ic 502 — 9y
0
You're welcome. Do note as I stated at the end of the question, there may be a more efficient way of solving your problem! Spongocardo 1991 — 9y
Ad

Answer this question