Post by Nikaas on Aug 4, 2017 20:02:16 GMT
Hi,
Noticed that ProCamera2DLimitDistance doesn't behave well in some situations.
I made a custom extension (based on ProCamera2DCameraWindow) that have the camera window move around the screen based on target position (actually based on CameraTargetPositionSmoothed) relative to camera position. But the thing about that extension is that camera window doesn't always "include" the center of the screen (and because the camera window in ProCamera2DCameraWindow always includes the center of the screen it works well with ProCamera2DLimitDistance). The actual problem with ProCamera2DLimitDistance - upon hitting one of the limits the extension resets CameraTargetPositionSmoothed to the center of the screen and that reset of position disrupts the custom extension (suddenly CameraTargetPositionSmoothed is far out of the camera window).
The problem is in lines 77-79:
I think ProCamera2DLimitDistance would work better if that code is replaced to:
Edit: I played a bit more and saw the option to offset the camera window in ProCamera2DCameraWindow. If you offset the camera window to not include the center of the screen (say on x) and hit one of the side limits on ProCamera2DLimitDistance you will notice the problem.
Nikola Kasabov
Noticed that ProCamera2DLimitDistance doesn't behave well in some situations.
I made a custom extension (based on ProCamera2DCameraWindow) that have the camera window move around the screen based on target position (actually based on CameraTargetPositionSmoothed) relative to camera position. But the thing about that extension is that camera window doesn't always "include" the center of the screen (and because the camera window in ProCamera2DCameraWindow always includes the center of the screen it works well with ProCamera2DLimitDistance). The actual problem with ProCamera2DLimitDistance - upon hitting one of the limits the extension resets CameraTargetPositionSmoothed to the center of the screen and that reset of position disrupts the custom extension (suddenly CameraTargetPositionSmoothed is far out of the camera window).
The problem is in lines 77-79:
ProCamera2D.CameraTargetPositionSmoothed = new Vector2(
horizontalExtra ? Vector3H(ProCamera2D.LocalPosition) + horizontalDeltaMovement : ProCamera2D.CameraTargetPositionSmoothed.x,
verticalExtra ? Vector3V(ProCamera2D.LocalPosition) + verticalDeltaMovement : ProCamera2D.CameraTargetPositionSmoothed.y);
I think ProCamera2DLimitDistance would work better if that code is replaced to:
ProCamera2D.CameraTargetPositionSmoothed = new Vector2(
horizontalExtra ? ProCamera2D.CameraTargetPositionSmoothed.x + horizontalDeltaMovement : ProCamera2D.CameraTargetPositionSmoothed.x,
verticalExtra ? ProCamera2D.CameraTargetPositionSmoothed.y + verticalDeltaMovement : ProCamera2D.CameraTargetPositionSmoothed.y);
Edit: I played a bit more and saw the option to offset the camera window in ProCamera2DCameraWindow. If you offset the camera window to not include the center of the screen (say on x) and hit one of the side limits on ProCamera2DLimitDistance you will notice the problem.
Nikola Kasabov