MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 07 Feb 2016 03:03 PM |
Right now I'm trying to make an over-the-shoulder camera, not using MouseLock or the default camera. It uses UserInputService for MouseMovement. I'm having an issue where UIS is not catching on to MouseMovement, while another function using the same exact "if" layout does.
The following code is commented to make it easier for you to follow along. There is no error output, but the only non-code output is "locking," which indicates that one thing does work. You'll see multiple "print"s throughout, but only one actually works. Here's the code:
function CameraModule:ControlRotation() --controls camera rotation repeat wait() until self.Player ~= nil --CameraModule is a big module, Player is an index local MouseDown = false --mouse stopped moving local InitialX = 0 --delta local InitialY = 0 --delta local InitialXRotation = self.RotationCFrame[1] --original X rotation, for spinning the camera horizontally local InitialYRotation = self.RotationCFrame[2] --original Y rotation, for tilting the camera vertically UIS.InputBegan:connect(function(InputObject) --UIS is defined if InputObject.UserInputType == Enum.UserInputType.MouseMovement then --if the input is mouse movement if MouseDown == false then --if the mouse was originally stationary print'beginning to rotate' MouseDown = true --indicates that the mouse is in a moving state --[[local InitialX = InputObject.Delta.X local InitialY = InputObject.Delta.Y local DiffX = InitialX local DiffY = InitialY]] else --if the mouse was already moving, then move it some more print'currently rotating' local DiffX = InitialX - InputObject.Delta.X --the direction the mouse is heading in local DiffY = InitialY - InputObject.Delta.Y --the direction the mouse is heading in self.RotationCFrame[1] = math.rad(DiffX)/4 + InitialXRotation --taking that difference and adding it self.RotationCFrame[2] = math.rad(DiffY)/4 + InitialYRotation --taking that difference and adding it if self.RotationCFrame[2] > math.rad(25) then --self.RotationCFrame[2] is the vertical tilt, has limits self.RotationCFrame[2] = math.rad(25) --self.RotationCFrame[2] is the vertical tilt, has limits end if self.RotationCFrame[2] < math.rad(-80) then --self.RotationCFrame[2] is the vertical tilt, has limits self.RotationCFrame[2] = math.rad(-80) --self.RotationCFrame[2] is the vertical tilt, has limits end end end end) --end of InputBegan event UIS.InputEnded:connect(function(InputObject) --UIS is defined if InputObject.UserInputType == Enum.UserInputType.MouseMovement then --if the input is mouse movement print'no more rotating' MouseDown = false --indicates that the mouse is no longer in a moving state end end) end
function CameraModule:MouseBehavior(GraphicalUserInterface) --GraphicalUserInterface is defined UIS.MouseIconEnabled = false --gets rid of the default mouse GraphicalUserInterface:AcquireCursor() --ads in a custom mouse, GUI is another module UIS.InputChanged:connect(function(InputObject) --UIS is defined if InputObject.UserInputType == Enum.UserInputType.MouseMovement then --if the input is mouse movement print'locking' UIS.MouseBehavior = Enum.MouseBehavior.LockCenter --locks the mouse to the center of the screen end end) end
function CameraModule:Initiate(GraphicalUserInterface) --initiates all needed functions to make this module work self:AssignPlayer() self:AssignCamera() self:ControlZoom() self:ControlRotation() self:LockOnShoulder() self:MouseBehavior(GraphicalUserInterface) end
If you could solve this issue or help, I'll be grateful.
https://www.youtube.com/MrSquerRBX | https://youtu.be/T4UL_aOl7j4 | https://youtu.be/WpOCu3Fm-S4 |
|
|
| Report Abuse |
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 07 Feb 2016 03:28 PM |
Bump
https://www.youtube.com/MrSquerRBX | https://youtu.be/T4UL_aOl7j4 | https://youtu.be/WpOCu3Fm-S4 |
|
|
| Report Abuse |
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 07 Feb 2016 04:33 PM |
I modified it a bit and put it on Pastebin http://pastebin.com/NriJb0fL
https://www.youtube.com/MrSquerRBX | https://youtu.be/T4UL_aOl7j4 | https://youtu.be/WpOCu3Fm-S4 |
|
|
| Report Abuse |
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 07 Feb 2016 06:17 PM |
Bump
https://www.youtube.com/MrSquerRBX | https://youtu.be/T4UL_aOl7j4 | https://youtu.be/WpOCu3Fm-S4 |
|
|
| Report Abuse |
|
MrSquer
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 6103 |
|
|
| 08 Feb 2016 03:07 PM |
Buawmp
https://www.youtube.com/MrSquerRBX | https://youtu.be/T4UL_aOl7j4 | https://youtu.be/WpOCu3Fm-S4 |
|
|
| Report Abuse |
|