Author Topic: Constraint rotation of globe/camera only near poles  (Read 1174 times)

i_varus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Constraint rotation of globe/camera only near poles
« on: November 14, 2018, 09:21:57 AM »
Our goal is to give player the whole freedom of camera rotation around the globe except we want to exclude any possibility for him to turn over the pole, even in the "Keep straight" mode.
Our solution is to constraint the rotation, so camera could never look at position near (0 -0.5 0) and (0 0.5 0) within given angle, where (0 -0.5 0) is coordinate of south pole, and (0 0.5 0) - north.
As far as we have researched there is no possible way to achieve desired effect without intervention in the interaction mechanics code.
So there are few questions:
1) Could be such feature requested to be implemented by your team?
2) If not, is there way to add such behavior on top of your interaction mechanics but without intervention in your code?
« Last Edit: November 16, 2018, 12:19:01 AM by Kronnect »

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5733
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #1 on: November 14, 2018, 03:35:40 PM »
Would that be similar to Constraint Rotation option + Allowed Axis option?

1) It's not planned atm.
2) You could try some clamp rotation script that takes place in LateUpdate() event although to avoid any side effect or provide a smoother effect it should be implemented into the asset itself.

We could add this in a future update although can't give you an ETA. If you're in a hurry and need a custom solution please send me a pm.
Regards

i_varus

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #2 on: November 15, 2018, 02:37:09 PM »
Would that be similar to Constraint Rotation option + Allowed Axis option?

1) It's not planned atm.
2) You could try some clamp rotation script that takes place in LateUpdate() event although to avoid any side effect or provide a smoother effect it should be implemented into the asset itself.

We could add this in a future update although can't give you an ETA. If you're in a hurry and need a custom solution please send me a pm.
Regards

It's like the inverse of Constraint Rotation mechanic, where you are not allowed to look at the and near specified position within some angle. And there are two such positions, i.e. poles, let me explain in pictures (I am sorry for this :D):


Where red arrows are forbidden directions of our camera.

And this camera perspective is not allowed:


It looks like a nice complement to Keep Straight mechanic because it helps to avoid unwanted situations, where player could loose his orientation, such as camera looking upside-down relatively to usual picture of the globe. Like this (it is in Keep Straight mode):



We are not in a hurry and and would be happy if you just confirm to take the implementation in near future.

Thank you.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5733
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #3 on: November 16, 2018, 12:18:52 AM »
Thanks for the details, I appreciate it.

Yes, it will be added to the roadmap, although can't give you an ETA.

Cheers

michaeltepl

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #4 on: May 03, 2020, 07:26:45 AM »
Hi! Any updates on this feature request?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5733
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #5 on: May 05, 2020, 02:39:41 AM »
Hi,
Latest beta includes a "Contraint Latitude" option which allows you to restrict the min/max rotation (ie. from -70 to 70 degrees).
Regards

michaeltepl

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #6 on: May 19, 2020, 04:20:48 AM »
Hi! There is one issue with this feature - when I enable orbit, change pitch value, for example, from 0 to 5 and back to 0, then rotation constraint stops working, because currentPitch value is not equal to zero (its 0.0001f), though pitch is 0

Code
void KeepCameraStraight(Camera cam) {
            if (currentPitch != 0) return; // This check is not working both with zero check and Mathf.Approximately.
            if (_keepStraight && !flyToActive) {
                if (_navigationMode == NAVIGATION_MODE.EARTH_ROTATES) {
                    StraightenGlobe(SMOOTH_STRAIGHTEN_ON_POLES, true);
                } else {
                    pivotTransform.rotation = Quaternion.Lerp(pivotTransform.rotation, GetCameraStraightLookRotation(), 0.3f);
                }
            }
        }


Regards

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 5733
    • View Profile
Re: Constraint rotation of globe/camera only near poles
« Reply #7 on: May 20, 2020, 10:31:04 AM »
Yes, reproduced and fixed. Please try the latest beta.