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

How to make player's head move on Y axis only?

Asked by 9 years ago

How did this game get his head to follow the mouse on the Y axis (as in looking up or down and not left or right)

(Game Link = "http://www.roblox.com/games/15110690/Zombie-Defense-Tycoon")

I attempted it but my one moves in ALL directions which I don't want it to, I want it to only work on the Y axis, when the player looks up and down.

utl.USI.InputChanged:connect(function(input)

if (input.UserInputType == Enum.UserInputType.MouseMovement) then

weld.C1 = CFrame.new(char.Head.CFrame.p,mouse.Hit.p):toObjectSpace(char.Torso.CFrame)

end

end

2 answers

Log in to vote
0
Answered by 9 years ago

I have answered this type of question before, you can find my answer here.

While it may be for moving arms with the mouse in an FPS, the script basically moves the neck around so it simulates movement on the Y axis of the head.

Hope this helps you.

0
Thank you, it works and only follows the Y axis! StrikerBOY606 50 — 9y
0
No problem. Spongocardo 1991 — 9y
0
Would there be a way to make this so it only rotates horizontally? drew1017 330 — 9y
Ad
Log in to vote
0
Answered by
OniiCh_n 410 Moderation Voter
9 years ago

Hm, I'm not very familiar with CFrames, but you might want to isolate the Y coord in the welds.

Maybe instead of char.Head.CFrame.p and mouse.Hit.p you could to something like char.Head.CFrame.y and mouse.Hit.y?

Not entire familiar with CFrames, but you can do that. You may want to also explicitly state the X and Z coords, to keep the head from turning left, right, and diagonally...

0
weld.C1 = CFrame.new(char.Head.CFrame.y,mouse.Hit.y):toObjectSpace(char.Torso.CFrame) and the output displayed this: bad argument #1 to 'new' (Vector3 expected, got number) StrikerBOY606 50 — 9y

Answer this question