Hello. I have been working on a camera system for a new game I plan to be working on shortly. However, I’ve come across an issue. After switching my localscript camera system to a more module-focused system, it has been experiencing issues.
Code (Module Script Loaded by LocalScript):
Input.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
xAngle = xAngle - input.Delta.x * 0.4;
yAngle = math.clamp(yAngle - input.Delta.y * 0.4, -80, 80);
end
end)
One thing I want to point out is that, in this code, the input object is received. The delta simply prints as 0 all the time. (Yes, the mouse behavior is set to lock center)
If anyone has any ideas as to why the input.Delta is returning zero, that’d be appreciated. Thank you.
EDIT: I’ve found that it will register in the first half a second of the game loading and then return to zero afterwards.
The function provided above is the only function that modifies the variables xAngle and yAngle. That’s why I can only assume it’s either a bug or a logic error in my code.
Managed to fix it. The Mouse Behavior was set to default because the Roblox core scripts loaded after my modules changed the behavior. I’ve fixed it by running the change every render step if the mouse behavior ~= locked. Thanks for the help everyone.
Ah ok, just so you know indexing that might be an unnecessary performance impact. You might want to have preliminary connection that you override once its property is correct. That is unless you plan on changing the mouse behavior a lot
That is what I thought about, so I might bring it up here again in the future. For now, I have it that way because I may support multiple camera types in the future. However, the mouse behavior may just need to be set once.