Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.74k stars 332 forks source link

camera clamping fix #2704

Open ArshvirGoraya opened 1 month ago

ArshvirGoraya commented 1 month ago

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:

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).

petchema commented 3 weeks ago

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.

That looks like a good reason to keep the clamping inside the setter indeed, so why pick the other solution?

ArshvirGoraya commented 2 weeks ago

That looks like a good reason to keep the clamping inside the setter indeed

Two solutions that keep the clamping in the setter function are here. I have implemented solution 2 in my last commit as it has the least problems.

Solution 1:

Solution 2:

I have implemented solution 2 in the previous commit and everything works as intended. I also tested with inverted mouse setting and everything works fine. Feel free to suggest any changes!!

Here is footage of everything working if anyone is curious: https://streamable.com/ujrcak