|
| 19 Mar 2017 01:10 PM |
| I've tried to put the camera inside the head and make the camera point to mouse.Hit.p but thats extremely buggy, I dont like using firstpersonlock because I want to make something more natural for my game? What would be the process to make this? |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 01:21 PM |
Change camera type to scriptable, and using renderstepped event update it's cframe to be inside the player's head, however don't mess with the rotation yet.
Keep track of it's current rotation in the script using variables, and whenever the mouse is moved just update the rotation's accordingly. So it'll look something like this:
local x,y = 0,0,0
renderstepped:connect(function() cam.CFrame = head.CFrame * CFrame.Angles(0,y,0) * CFrame.Angles(x,0,0) end)
And then use the userinput changed event to update the x and y variables whenever the mouse moves
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputChanged |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 01:23 PM |
That's just the general idea, you'll have to play with the specifics. However, I did make a mistake. Don't use the head cframe, use it's position instead so the rotation based on the variables will always be the same
cam.CFrame = CFrame.new(head.Position)--then rotate |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 01:24 PM |
| Roy's solution is beautifully simple. The only other thing I'd add is analog stick support, too. |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 01:31 PM |
| thanks, im assuming i have to use mouse.Move to get these x and y variables? |
|
|
| Report Abuse |
|
|
|
| 19 Mar 2017 01:56 PM |
| No. Look at the link I provided, it explains how to do it there. Specifically, look at the printMovement function. |
|
|
| Report Abuse |
|
|
| |
|