Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Camera pitchMin and pitchMax Clamping
Problem:
Expected behaviour of
pitchMin
: limits how far you can look down.Expected behaviour of
pitchMax
: limits how far you can look up.Current Behaviour: Whichever value is closer to 0, sets both the minimum and maximum of how far the camera can look up/down.
Example:
pitchMax = 10
andpitchMin = -90
: look up to 10, but can only look down to -10 (even with pitchMin set to -90).pitchMax = 90
andpitchMin = -10
: look down to -10, but can only look up to 10 (even with pitchMax set to 90).Why its Happening:
This happens because the code clamps the pitch value twice. Inside the
update()
and inPitch
's setter function.This wouldn't be a problem if we weren't also switching the value's sign before the setter function, which results in the value being clamped in its sign-flipped state as well as its normal state.
Examples
Positive Value:
Negative Value:
Solution:
Remove the
Mathf.Clamp()
call inside the setter function. The update function clamps this value anyway, so the clamping is still working, but just on Update().A problem with this solution is a mod may rely on the clamping in the setter function, not the Update(). So, an alternative solution may be better. Otherwise, those mods would have to update (e.g., clamp the value themselves before assigning to
Pitch
).